Php+mysql Page Login Code

Source: Internet
Author: User

Login Screen Settings:

<?php
/**
* Created by XX.
* User:msi
* DATE:2017/10/26
* Time:18:12
*/
The session must be enabled before each use!! , with start!
Session_Start ();
Var_dump ($_session);
?>
<! DOCTYPEHtml>
lang="EN">
<metacharset="UTF-8">
<title>title</title>
<body>
<formaction="Login_post.php"Method="POST">
<table>
<tr>
<td> User name:</td>
<td><inputType="Text"Name="Uname"Placeholder="Please enter your account"></td>
</tr>
<tr>
<td> Password:</td>
<td><input type="password" name="Pwod" placeholder="Please enter password"></td>
</tr>
</table>
<input type="Submit" value="Login">
</form>
</body>

Login Processing Interface Setup code:
<?php
/**
* Created by XX.
* User:msi
* DATE:2017/10/26
* TIME:18:15
*/
Session_Start ();
Header"Content-type:text/html; Charset=utf-8 ");
Require_once".. /public/dbda.class.php ";
$db=NewDbda ();
First check the user name entered, and then according to the user name entered to the database to check the password, and finally verify that the password and MySQL inside the password match!
$sql="SELECT * from t_user WHERE uname = '{$_post["Uname"]}' And Pwod = '{$_post["Pwod"]}‘";
As long as it's not 1.
$result=$db-Strquery($sql);

If($result!="0"){
Echo"Successful Landing";
$_session[' User '] =Array(
' Uname '=' User1 ',
);
Var_dump ($_session);
}else {
echo }
//detects session information->
If session information is empty, then jump to login interface
if (empty ( $_session [ ' user ' ]) {
header ( Span style= "COLOR: #6a8759" > "location:login.php" ) ;
}
//log out and destroy the account information;
unset ($_session ) ;

This is done!
/span>
< Span style= "COLOR: #e8bf6a" > < Span style= "COLOR: #bababa" > < Span style= "COLOR: #e8bf6a" > < Span style= "COLOR: #e8bf6a" >&NBSP;         

Php+mysql Page Login code

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.