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