Today learned to do the background page, very failure will not show.
PHP: The following code can block PHP attention level error, that is, throw any non-attention errors
[PHP] Error_reporting (e_all&~e_notice);
Error_reporting (E_all&~e_notice);
Open the session method, you can use $_sesion after opening.
The session is something that is stored on the service side OH. After launch, it will send a session ID to the browser, which is the type of cookies
[PHP] Session_Start ();
Session_Start ();
It doesn't matter if the browser disables cookies, so you can write the session to the URL. Hey.
[PHP] session_name. ' = '. session_id ()
Session_name. ' = '. session_id () Attach the adminaction I wrote, only login function oh
[PHP] /**
*
**/
Class Adminaction extends Action
{
protected $db = ";
function __construct ()
{
Code ...
$smarty->force_compile = true;
/* $this->db = new MySQL ("127.0.0.1", "root", "1234", "myly", "data");
$this->db->table (' data '); */
$this->db = Mysql::getclass ();
Var_dump ($this->db);
$this->db, connect ("127.0.0.1", "root", "1234", "myly");
$this->db table (' user ');
Parent::__construct ();
}
Public Function Index ()
{
if ($this->is_login ()) {
echo "";
}else{
echo "";
}
}
Private Function Is_login ()
{
Return $_session[' login '];
}
Public Function Login ()
{
if (!empty ($_post[' userName ')) &&!empty ($_post[' password ']) {
$userName =$_post[' UserName '];
$password =md5 ($_post[' password ');
/*var_dump ($_post);
Var_dump ($password);
Var_dump ($password); * *
if ($_session[' UserData ']= $this->db->where ("Username= ' {$userName} ' and password= ' {$password} ')->fine ()) {
echo "";
$_session[' login ']=true;
}else{
echo "Login Failed";
}
}
$this->display ();
}
Public Function Ulogin ()
{
echo "";
Unset ($_session);
}
Public Function admin ()
{
if (! $this->is_login ()) {
echo "";
}
Var_dump ($_session);
$this->assign (' userName ', $_session[' userData ' [' userName ']);
$this->display ();
}
function Add () {
/*var_dump ($this->db
->data (
Array (' userName ' = ' admin ',
' Password ' = MD5 (' admin '),
' Time ' = Time ()
))
->add ());
*/
}
}
?>
/**
*
**/
Class Adminaction extends Action
{
protected $db = ";
function __construct ()
{
Code ...
$smarty->force_compile = true;
/* $this->db = new MySQL ("127.0.0.1", "root", "1234", "myly", "data");
$this->db->table (' data '); */
$this->db = Mysql::getclass ();
Var_dump ($this->db);
$this->db, connect ("127.0.0.1", "root", "1234", "myly");
$this->db table (' user ');
Parent::__construct ();
}
Public Function Index ()
{
if ($this->is_login ()) {
echo "";
}else{
echo "";
}
}
Private Function Is_login ()
{
Return $_session[' login '];
}
Public Function Login ()
{
if (!empty ($_post[' userName ')) &&!empty ($_post[' password ']) {
$userName =$_post[' UserName '];
$password =md5 ($_post[' password ');
/*var_dump ($_post);
Var_dump ($password);
Var_dump ($password); * *
if ($_session[' UserData ']= $this->db->where ("Username= ' {$userName} ' and password= ' {$password} ')->fine ()) {
echo "";
$_session[' login ']=true;
}else{
echo "Login Failed";
}
}
$this->display ();
}
Public Function Ulogin ()
{
echo "";
Unset ($_session);
}
Public Function admin ()
{
if (! $this->is_login ()) {
echo "";
}
Var_dump ($_session);
$this->assign (' userName ', $_session[' userData ' [' userName ']);
$this->display ();
}
function Add () {
/*var_dump ($this->db
->data (
Array (' userName ' = ' admin ',
' Password ' = MD5 (' admin '),
' Time ' = Time ()
))
->add ());
*/
}
}
?>
Submission Form single-login.html
[HTML]
Waterfall Flow Message Board backstage Login
Waterfall Flow Message Board backstage Login
Admin.html after the successful landing
[HTML]
Welcome to <{$userName}>
Welcome to <{$userName}>
This is my landing function.
Modified mysql.class.php added a function fine, so that the returned array is a one-dimensional, convenient
[PHP]/**
+----------------------------------------------------------
* Get a single record of a data table and return a one-dimensional array
+----------------------------------------------------------
* @access Public
+----------------------------------------------------------
* @param
+----------------------------------------------------------
*/
Public Function fine () {
$select _sql = ' SELECT ';
$fields = isset ($this->query_list[' Fields ') "$this->query_list[' Fields ']: ' * ';
$select _sql.= $fields;
$select _sql.= ' from '. $this->query_list[' table ']. ' ` ';
Isset ($this->query_list[' join ')? ($select _sql.= $this->query_list[' join '): ';
Isset ($this->query_list[' where ')? ($select _sql.= ' where '. $this->query_list[' where '): ';
Isset ($this->query_list[' group ')? ($select _sql.= ' GROUP by '. $this->query_list[' group '): ';
Isset ($this->query_list[' having ')? ($select _sql.= ' MySQL has '. $this->query_list[' having '): ';
Isset ($this->query_list[' order ')? ($select _sql.= ' ORDER by '. $this->query_list[' order ']): ';
Isset ($this->query_list[' limit ')? ($select _sql.= '): ';
Echo '
-----> '. $select _sql. ' <---------
';
return $this->query ($select _sql) [0];
}
/**
+----------------------------------------------------------
* Get a single record of a data table and return a one-dimensional array
+----------------------------------------------------------
* @access Public
+----------------------------------------------------------
* @param
+----------------------------------------------------------
*/
Public Function fine () {
$select _sql = ' SELECT ';
$fields = isset ($this->query_list[' Fields ') "$this->query_list[' Fields ']: ' * ';
$select _sql.= $fields;
$select _sql.= ' from '. $this->query_list[' table ']. ' ` ';
Isset ($this->query_list[' join ')? ($select _sql.= $this->query_list[' join '): ';
Isset ($this->query_list[' where ')? ($select _sql.= ' where '. $this->query_list[' where '): ';
Isset ($this->query_list[' group ')? ($select _sql.= ' GROUP by '. $this->query_list[' group '): ';
Isset ($this->query_list[' having ')? ($select _sql.= ' MySQL has '. $this->query_list[' having '): ';
Isset ($this->query_list[' order ')? ($select _sql.= ' ORDER by '. $this->query_list[' order ']): ';
Isset ($this->query_list[' limit ')? ($select _sql.= '): ';
Echo '
-----> '. $select _sql. ' <---------
';
return $this->query ($select _sql) [0];
}
http://www.bkjia.com/PHPjc/477413.html www.bkjia.com true http://www.bkjia.com/PHPjc/477413.html techarticle today learned to do the background page, very failure will not show. PHP aspect: The following code can block PHP attention level error, that is, throw any non-attention error [PHP] error_reporting (e_ ...