0
任何人都可以幫助我究竟在哪裏出錯本代碼?當我正在檢查數據庫中是否存在電子郵件時,我錯了。試圖檢查用戶輸入的郵件是否已在數據庫中
如何檢查數據庫中是否存在郵件?
<html>
<h1> Registration Form </h1>
<body>
<form method="post" action="">
<input type="text" name="fname" placeholder="first name" required><br><br>
<input type="text" name="lname" placeholder="last name" required><br><br>
<input type="text" name="mail" placeholder="mail" required> <br><br>
<input type="PASSWORD" name="pass1" placeholder="password" required> <br><br>
<input type="PASSWORD" name="pass2" placeholder="repeat password" required> <br> <br>
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$mail = $_POST['mail'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
if($pass1 !== $pass2)
{
echo "password in correct ";
}
else
{
$db = mysqli_connect("localhost","root","","reviewsystem");
$check = "SELECT * FROM registers WHERE $mail = email";
if($check == TRUE){
echo "email already exists";
}
else{
$query = "INSERT INTO registers(fname,lname,email,password) VALUES('$fname','$lname','$mail','$pass1')";
mysqli_query($db,$query);
echo " you are registered succesfully";
}
}
}
?>
</body>
</html>
@KrishnaKamal是的,只是注意到查詢錯誤以及。將其更改爲'「SELECT * FROM registers WHERE email ='$ mail'」' – DannyPhantom
現在完美。謝謝! @danny –