PHP Login Code _php Tutorial

Source: Internet
Author: User
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






Control Panel




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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.