PHP Entry User Login instance code and tutorial

Source: Internet
Author: User

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

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.