Registration verification has failed
Require_once ' db.php ';
Session_Start ();
$name = $_post["name"];
$mail = $_post["email"];
$pwd = $_post["Key"];
$pwd 2 = $_post["rekey"];
$agreement = $_post["agreement"];
if ($agreement = = "T") {
if ($pwd = = $pwd 2) {
$sql = "SELECT * from user";
$result = $db->query ($sql);
if ($result && $row = $result->fetch_assoc ()) {
if ($name = = $row ["name"]) {
Echo ' ";
Exit
}elseif ($mail = = $row ["Mail"]) {
Echo ' ";
Exit
}else{
$sql = "INSERT into user (Name,represent,pwd,mail,time) value (' {$name} ', 0, ' {$pwd} ', ' {$mail} ', now ())";
$result = $db->query ($sql);
if ($result && $db->affected_rows>0) {
$sql = "SELECT * from user where name= ' {$name} '";
$result = $db->query ($sql);
if ($result && $row = $result->fetch_assoc ()) {
$uid = $row [' uid '];
}
}
$result->free_result;
$db->close;
$sql = "INSERT into Userphoto (uid,name,type,url,size,time) value (' {$uid} ', ' Steve ', '. png ', './img/userphoto/steve.png ', ' 6.24kb ', Now ()) ";
$result = $db->query ($sql);
if ($result && $db->affected_rows>0) {
Echo ' ";
Exit
}else{
Echo ' ";
Exit
}
}
}
$result->free_result;
$db->close;
}else{
Echo ' ";
Exit
}
}else{
Echo ' ";
Exit
}
$result->free_result;
$db->close;
?>
The user already exists, this has been failed to verify, each registration of the same user name is successful, should be how to change?
------to solve the idea----------------------
$sql = "SELECT * from user";???
The result of this SQL execution, you know?
He will return all records in the user table, and you only take out the first record $row = $result->fetch_assoc ()