Php getting started tutorial simple php user logon complete tutorial-PHP source code

Source: Internet
Author: User
This is a simple php user logon complete tutorial I wrote previously. If you are a beginner, come in and check out this tutorial. This is a simple php user logon complete tutorial I wrote previously. If you are a beginner, come in and check out this tutorial.

Script ec (2); script

@ Session_start ();
Mysql tutorial _ connect ('localhost', 'root', '123') or die ('database server no exists! ');
Mysql_select_db ('wk ') or die ('database error! ');
Mysql_query ("set names 'gbk'"); // set document charset encode

$ Uid = get_value ('U', 'post ');
$ Login_pwd = get_value ('P', 'post ');
If (strlen ($ uid) <3 | strlen ($ uid)> 12 ){
Alert ('user length is 3-12 characters! ','');
} Elseif (strlen ($ login_pwd) <6 | strlen ($ login_pwd)> 12 ){
Alert ('the logon password is incorrect, the length is 6-12 bits ','');
} Else {
$ SQL = "select * from wk_member where m_uid = '$ uid' and m_pass =' $ login_pwd '";
$ Result = mysql_query ($ SQL) or die (mysql_error ());
If (mysql_num_rows ($ result )){
$ Rs = mysql_fetch_array ($ result );
If ($ rs ['m _ pass']! = Md5 ($ login_pwd )){
Alert ('user name and password do not match! ','');
} Else {
$ _ SESSION ['uid'] = array ($ rs ['id'], $ uid, $ rs ['m _ tel ']);
Exit ("script location = 'registerok. php'; script");
}
} Else {
Alert ('login failed, user name does not exist! ','');
}
}

Function get_value ($ st, $ str = 'get ')
{
If ($ str = 'post ')
{
Return $ _ POST [$ st];
} Else {
Return $ _ GET [$ st];
}
}

?>

// Wk_member structure of the data table
Id
M_uid
M_pass

Original site reprinted with www.111cn.net

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.