PHP Registration Review (0523)

Source: Internet
Author: User

Once registered, the information will be saved to the session and approved before being added to the database.

The information that is added to the database is logged in after the audit passes after the status becomes passed. If the user's bad behavior is found, it can be revoked.

Registration page:

1<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Registration </title>67 8<body>9Ten<form action= "zcchuli.php" method= "POST" > One<div> AUser name: <input type= "text" name= "uid"/><br/><br/> -Password: <input type= "text" name= "PSW"/><br/><br/> -Name: <input type= "text" name= "name"/><br/><br/> theGender: <input type= "text" name= "sex"/><br/><br/> -Birthday: <input type= "text" name= "Birthday"/><br/><br/> -<input type= "Submit" value= "register"/> -</div> +</form> -  +</body> AView Code

Registration processing: (to be audited after successful registration)

1<?PHP2 include(".. /dbda.class.php ");3 $db=NewDbda ();4 $uid=$_post["UID"];5 $PSW=$_post["PSW"];6 $name=$_post["Name"];7 $sex=$_post["Sex"];8 9 $s=1;Ten if($sex= = "female") One { A     $s=0; -     } -  the $birthday=$_post["Birthday"]; -  -  - $sql= "INSERT into Users values (' {$uid}‘,‘{$PSW}‘,‘{$name}‘,{$s},‘{$birthday} ', False) '; +  - //echo $sql; + $r=$db->query ($sql, 1); A  at if($r) - { -     Header("location:zhuce.php"); -     } - Else - { in     Echo"Registration failed!"; -}
View Code

Login page:

1<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Login </title>67 8<body>9Ten<form action= "dlchuli.php" method= "POST" > One<div> AUser name: <input type= "text" name= "uid"/><br/><br/> -  -Secret &nbsp;&nbsp; code: <input type= "text" name= "PSW"/><br/><br/> the  -<input type= "Submit" value= "Login"/> -</div> -</form> +  -</body> +View Code

Login Processing: (Audit pass to log in)

1<?PHP2 Session_Start();3 include(".. /dbda.class.php ");4 $db=NewDbda ();5 6 $uid=$_post["UID"];7 $PSW=$_post["PSW"];8 9 $sql= "SELECT count (*) from users where Uid= ' {$uid} ' and psw= ' {$PSW} ' and Isok=true ';Ten  One $r=$db->strquery ($sql); A  - if($r==1) - { the     $_session["UID"]=$uid; -     Header("location:main.php"); -     } - Else + { -     Header("location:denglu.php"); +}
View Code

Audit Main Page: (Visible only to administrators)

1<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Audit </title>67 8<body>9Ten  One<table width= "100%" border= "1" cellpadding= "0" cellspacing= "0" > A<tr> -<td> name </td> -<td> Sex </td> the<td> Birthdays </td> -<td> Status </td> -</tr> -  +<?PHP - include(".. /dbda.class.php "); + $db=NewDbda (); A $sql= "SELECT * from Users"; at $attr=$db->query ($sql); - foreach($attr  as $v) - { -      -     //State judgment isOK -     $zt=""; in     if($v[5]) -     { to         $zt= "<span style= ' Color:green ' > passed </span>&nbsp;<a href= ' chexiao.php?uid={$v[0]} ' > Undo </a> "; +         } -     Else the     { *         $zt= "<a href= ' shchuli.php?uid={$v[0]} ' > Audit </a> "; $         }Panax Notoginseng      -      the     Echo"<tr> +<td>{$v[2]}</td> A<td>{$v[3]}</td> the<td>{$v[4]}</td> +<td>{$zt}</td> -</tr> "; $      $     } -  -?> the</table> -</body>WuyiView Code

Audit Processing: (Audit success Show passed)

1<?PHP2 $uid=$_get["UID"];3 4 include(".. /dbda.class.php ");5 $db=NewDbda ();6 7 $sql= "Update users set isok=true where uid= ' {$uid}‘";8 9 if($db->query ($sql, 1))Ten { One     Header("location:main.php"); A     } - Else - { the     Echo"Audit Failed!" "; -}
View Code

Undo Processing: (Revocation audit, unable to login)

1<?PHP2 $uid=$_get["UID"];3 include(".. /dbda.class.php ");4 $db=NewDbda ();5 $sql= "Update users set Isok=false where uid= ' {$uid}‘";6 if($db->query ($sql, 1))7 {8     Header("location:main.php");9     }Ten Else One { A     Echo"Undo Failed!" "; -}
View Code

page Run display:

PHP Registration Review (0523)

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.