Napisałem sobie rejestrację do panelu logowania i mam problem. Niby sprawdza czy istnieje użytkownik już taki podczas rejestracji i czy hasła się zgadzają no i czy mail już taki jest w bazie ale jak zmienię e-mail i hasła się zgadzają to rejestruje mimo że użytkownik już istnieje w bazie. Co jest nie tak? Kod:
<?php
$nick= $_POST['user'];
$password= $_POST['password'];
$email= $_POST['email'];
$repassword= $_POST['repassword'];
$user= $nick;
$mail= $email;
$use= mysql_query ("SELECT user FROM base WHERE user='".$_POST['user']."' AND email='".$_POST['email']."'");
$chuser= $check['user'];
$chmail= $check['email'];
}
if (!empty($nick) && !empty($password) && !empty($email) && !empty($repassword)) { // => Type all information
if ($user!= $chuser && $repassword== $password && $mail!= $chmail) {
$records= "INSERT INTO `base` (`user`, password, email) VALUES ('$nick','$password','$email');";
echo 'You have been registered :)';
}
else {
echo 'This user already exists/ Typed password are not the same/E-mail is registered';
}
} //end empty
else {
echo 'Type all information';
}
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> <meta http-equiv="Content-type" content="application/xhtml+xml; charset=iso-8859-2" /> <meta name="Description" content="Something" /> <meta name="Keywords" content="Something" /> <meta name="Author" content="Author " /> <link rel="Stylesheet" href="style.css" type="text/css" />
<form action="register.php" method="post"> <br /><input type="submit" value="Send" /><br />