First step
/*
First create the data table directly copy to your phpMyAdmin directly run on OK. 1
CREATE TABLE IF not EXISTS ' useradmin ' (
' ID ' int (4) not NULL auto_increment,
' username ' varchar default NULL,
' userpass ' varchar default NULL,
' Logins ' int (4) Not NULL default ' 0 ' COMMENT ' landing times ',
' Logintime ' timestamp not NULL default current_timestamp on Update Current_timestamp,
' Mid ' char (1) Not NULL default ' 0 ',
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT Charset=utf8 auto_increment=4;
*/
Second Step
Create a new PHP file with DW
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>
<body>
<form name= "Form1" method= "Post" action= "" >
<label>
<input name= "uname" type= "text" id= "uname" >
</label>
<label> <br>
<br>
<input name= "password" type= "password" id= "password" >
</label>
<p>
<label>
<input type= "Submit" name= "Submission" value= "submitted" >
</label>
</p>
</form>
</body>
Third Step
mysql_connect (' localhost ', ' root ', ' root ') or Die (Mysql_error ());/host name, MySQL username, mysql password
mysql_select_db (' 111cnNet '); Database name
mysql_query ("Set Names ' GBK '"); Set code, or easily garbled, the best database and page editing consistent
if (Isset ($_get[' uname ')) && isset ($_get[' password '])
{
$uname = $_get[' uname '];
$password = MD5 ($_get[' password ')); MD5 in PHP is a built-in function of the system, unlike the ASP tutorial user Self Righteous
Now construct the SQL statement
$sql = "SELECT * from Useradmin where username= ' $uname ' and userpass= ' $password ' limit 1";
$query = mysql_query ($sql);
if (mysql_num_rows ($query))
{
Echo ' Login succeeded ';
}
Else
{
Echo ' Login failed, username password incorrect ';
}
}
Okay, OK, this site original tutorial reproduced please indicate the source code tutorial Www.111cn.net
Take a look at this PHP entry user login instance code and tutorial