PHP Login Code This is an example of a compiled PHP login code Oh, he from the database to the HTML and PHP program, the entire process is written step by step, is a very good entry-level login PHP code.
PHP Tutorial Login Code
This is an example of the completion of the PHP login code, OH, he from the database tutorial to HTML and PHP program, the whole process has been written in step by step, is a very good entry-level login PHP code.
*/
Session_Start ();
/* Get post */
if (!function_exists ("Getpost")) {function getpost () {if (count ($_post)) {foreach ($_post as $key = = $value) {Global ${$ key};${$key}= $value;}}}
/* Get Get */
if (!function_exists ("Getget")) {function Getget () {if (count ($_get)) {foreach ($_get as $key = = $value) {Global ${$key} ; $ $key = ($value);}}}
/* SQL Escape String */
if (!function_exists ("Escapeit")) {
function Escapeit ($text) {
if (GET_MAGIC_QUOTES_GPC ()) $text =strips Tutorial Lashes ($text);
if (!is_numeric ($text)) $text =mysql tutorial _real_escape_string ($text);
return $text;
}}
Getpost (); Get the data that comes in post
Login
$rs = $db->query ("select * from ' backend_user ' where binary ' login ' = '". Escapeit ($login). "' and binary ' password ' = '" . MD5 ($password). "'");
if (mysql_num_rows ($rs) > 0) {
$row = $db->fetch_array ($rs);
$_session["Smartinfo_sysid"] = $row ["user_id"];
$_session["Smartinfo_syslogin"] = $row ["Login"];
$db->query ("Update ' Backend_user ' set ' last_logon ' = '". Date ("Y-m-d h:i:s"). "' where ' id ' = '". $row ["id"]. "'");
Header ("location:index2.php");
} else {
Header ("Location:index.php?status=fail");
}
The function to use
?>
HTML code
Database
--
--The structure of the table ' Backend_user '
--
CREATE table if not EXISTS ' backend_user ' (
' user_id ' int (one) not NULL auto_increment,
' group_id ' int (one) not null default ' 0 ',
' Login ' varchar (255) NOT null default ' ',
' Password ' varchar (255) NOT null default ' ',
' Last_logon ' datetime NOT NULL default ' 0000-00-00 00:00:00 ',
Primary KEY (' user_id ')
) Engine=myisam default Charset=utf8 auto_increment=2;
--
--Export the data in the table ' Backend_user '
--
Insert INTO ' backend_user ' (' user_id ', ' group_id ', ' login ', ' password ', ' Last_logon ') values
(1, 0, ' admin ', ' e10adc3949ba59abbe56e057f20f883e ', ' 0000-00-00 00:00:00 ');
http://www.bkjia.com/PHPjc/632032.html www.bkjia.com true http://www.bkjia.com/PHPjc/632032.html techarticle PHP Login Code This is an example of a compiled PHP login code Oh, he from the database to the HTML and PHP program, the whole process is written step by step, is a very good entry-level login ...