Create a Test form
<form action= "chuli.php" method= "POST" > <div> user name: <input type= "text" name= "UID"/></div> < div> Password: <input type= "password" name= "pwd"/></div> <div><input type= "Submit" value= "Login"/> </div></form>Chuli.PHP<?PHP$_post["UID"];$_post["PWD"];//Connecting Objects$db=NewMysqli ("localhost", "root", "123", "MyDB");//Write SQL statements$sql= "Select password from login Shere uid= ' {$uid}‘";//Execute SQL statement$resulat=$db->query ($sql);$n=$result-Fetch_row ();//Judging
if ($uid! = "" && $pwd! = ")
{if($n[0]==$PSD) {Header(Location:main.php);}Else{Echo"User name or password error";}
}
Else
{
echo "User name or password cannot be empty";
}
/*Write SQL statements, unsafe login methods
Injection Attack $sql = "SELECT count (*) from login where useename= ' {$uid} ' and passwoed= ' {$pwd} '";//Execute SQL statement $result = $db->qu ery ($sql); $n = $result-fetch_row (); if ($n [0]>0) {header ("location:main.php");} else{echo "username or password error";}*/
Injection attacks, this type of code is not safe to sign in
php-Database Access--Add, delete, change