PHP Simple User Login program code

Source: Internet
Author: User

These tutorials are very useful for beginners, oh, this is a little bit of code on the following OH.

<center>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name= "Form1" method= "Post" action= "login_cl.php" >
<table width= "height=" 241 "border=" 0 "cellpadding=" 0 "cellspacing=" 0 ">
&LT;TR align= "center" >
&LT;TD colspan= "2" bgcolor= "#999999" > Member Login Interface (login.php) |<a href= "index.php" > Back </a> </td>
</tr>
<tr bgcolor= "#CCCCCC" >
&LT;TD width= "137" align= "center" > User:</td>
&LT;TD width= "363" ><input name= "Yd631_name" type= "text" id= "Yd631_name" ></td>
</tr>
<tr bgcolor= "#D9D9D9" >
&LT;TD align= "center" > Password:</td>
<td><input name= "YD631_PWS" type= "password" id= "YD631_PWS" ></td>
</tr>
&LT;TR align= "center" bgcolor= "#CCCCCC" >
&LT;TD colspan= "2" ><input type= "Submission" name= "submit" value= "submitted" >
<input type= "reset" name= "submit" value= "reset" >

</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</center>

Log in PHP processing code

Include ("config.php");
?>
<?php
if (Empty ($_post["Yd631_name"])) {
Echo ("<script type= ' Text/javascript ' > Alert (') how can the user name be empty?" '); History.go ( -1);</script> ");
}
if (Empty ($_post["YD631_PWS"])) {
Echo ("<script type= ' Text/javascript" > alert (' Password cannot be empty!) '); History.go ( -1);</script> ");
}
$yd 631_name= $_post["Yd631_name"]; User name has been logged
$yd 631_pws= $_post["YD631_PWS"]; The password has been recorded.
$db =mysql_connect ($servername, $sqlservername, $SQLSERVERPWS);
mysql_select_db ($sqlname, $db);
$sql = "SELECT * from $sqltable where yd631_name= ' $yd 631_name ' and yd631_pws= ' $yd 631_pws '";
$result =mysql_fetch_array (mysql_query ($sql));
if (! $result) {
Echo (' <script type= ' text/javascript ' > Alert (' Username or password is incorrect! '); History.go ( -1);</script> ");
Mysql_close ();
Exit
}
if ($result ["Yd631_pass"]== "no") {
Verify that the member is approved
Echo ("<script type= ' Text/javascript" > Alert (' You haven't been audited yet!) '); History.go ( -1);</script> ");
}
Session_Start ();
$_session["name"]= "$yd 631_name";
echo "<script>location.href= ' yd631.php ';</script>";
?>

Config file.

<?php
General parameter settings

$servername = "localhost"; Host Name
$sqlservername = "root"; MySQL Database user name
$SQLSERVERPWS = "yd631"; MySQL Database password

$sqlname = "Yd631_user"; Database name
$sqltable = "Yd631_users"; Username Table name


$admin _name= "yd631"; Administrator user Name
$admin _pws= "yd631"; Administrator password
?>

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.