Employee Information Management System (2) Administrator database Login

Source: Internet
Author: User
Tags php source code

The results of the operation are as follows:

Login Page loginview.php.

Press the login button, jump to the login Processing page loginview.phploginprocess.php, after the database query, login failed, jump back to the login page loginview.php, and prompt error message.

Enter the correct account password, log in successfully, jump to the main page mainview.php.

The process for creating an employee information Management database (AEDB) using phpMyAdmin is as follows:

Create an Employee Information management database (AEDB).

In the Employee Information Management database (AEDB), create an Administrator table (AD).

In the Administrator table (AD), insert tuples.

(Note: MD5 () is used for encryption. The following example string parameter "123" after the MD5 function operation will get another string (called the MD5 value), can not be decrypted, thereby playing the role of cryptographic protection. For password authentication, the user is required to enter the MD5 value of the password, if the MD5 encrypted password in the database is the same, the validation succeeds. )

Loginview.php source code is as follows:

1<! DOCTYPE html>234<title> Employee Information Systems </title>5<meta http-equiv = "Content-type" content= "text/html; CharSet = Utf-8 ">6 7<style type= "Text/css" >8div.error{height:22px; width:150px; color:red; Size:2px;}9</style>Ten  One A<body bgcolor= "#ABC" > -<center> -<div style= "height:60px; width:50px "></div> the<!--to adjust the vertical position of the form-- -

-<form action= "loginprocess.php" method= "POST" > -<table> +<tr> -<th> Account </th> +<th><input type= "text" name= "id" ></input></th> A<th><divclass= "Error" &GT;&LT;?PHP at //div to prevent form error messages from affecting layout - //Determine the presence and display of form error messages - if(isset($_get[' Error '])) { - $error=$_get[' Error ']; -}Else{ - $error=0; in } - if($error==1) { to Echo"* Incorrect account or password! "; + } -?></div></th> the</tr> *<!--TR tag is the same line of content, the th tag is the same column content-- $<tr>Panax Notoginseng<th> Password </th> -<th><input type= "password" name= "password" ></input></th> the</tr> +<tr> A<th></th> the<th> +<input type= "Submit" value= "Login" ></input> -<input type= "reset" value= "reset" ></input> $</th> $</tr> -</table> -</form> the</center> -</body>Wuyiloginview.php

Loginprocess.php source code is as follows:

1<?PHP2 ////Set the encoding of PHP files3     Header("Content-type:text/html;charset=utf-8");4 //Accept User Data5     $id=$_post[' ID '];6     $password=$_post[' Password '];7 //Get Connected8     $conn=mysql_connect("localhost", "root", "root");9     if(!$conn) {Ten          die("Connection Failed! Error message: ".Mysql_errno()); One     } A //set the encoding for accessing the database -     mysql_query("Set Names UTF8",$conn) or die("Setup encoding failed!") Error message: ".Mysql_errno()); - //Select Database the     mysql_select_db("Aedb",$conn) or die("Failed to select database!") Error message: ".Mysql_errno()); - //Send SQL statement -     $sql= "Select password from AD WHERE id=$id"; - //get query result set +     $res=mysql_query($sql,$conn); - //determine if the query results exist and match exactly + //md5 (), a hash function widely used in the field of computer security to provide integrity protection of messages.  A     if(($row=Mysql_fetch_assoc($res)) &&$row[' Password ']==MD5($password)) { at //match success, jump to mainview.php -         Header("Location:mainview.php"); -          die(); -     } - //match failed, jump to loginview.php, and send error message -         Header("Location:loginview.php?error=1"); in          die(); -?>

Mainview.php source code is as follows:

1<! DOCTYPE html>234<title> Welcome to Employee information Management system </title>5<meta http-equiv = "Content-type" content= "text/html; CharSet = Utf-8 ">6 7<style type= "Text/css" >8div.d0{color:red; size:200px; Font-weight:700;text-align:Center;}9</style>Ten  One A<body bgcolor= "#ABC" > -<divclass= "D0" > Login success!! </div> -</body> themainview.php

Employee Information Management System (2) Administrator database login

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.