我在数据库中的电子邮件列上放置了唯一索引,当我输入已注册的电子邮件时,数据库不会更新。这样效果很好。我现在需要告诉用户输入已经存在的电子邮件(在注册页面上),它已经注册并将他们重定向到主页。
请检查我的 SQL 注入代码,如果有任何错误,请更正。
<?php
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$mobilenumber = $_POST['mobilenumber'];
//prevent sql injection
$fullname = stripslashes($fullname);
$email = stripcslashes($email);
$mobilenumber = stripslashes($mobilenumber);
$fullname = mysql_real_escape_string($fullname);
$email = mysql_real_escape_string($email);
$mobilenumber = mysql_real_escape_string($mobilenumber);
//Database Connection
$conn = new mysqli("#","#","#","#");
if($conn->connect_error){
die('connection Failed : '.$conn->connect_error);
}else{
$stmt = $conn->prepare("insert into signup(fullname,email,mobilenumber)values(?,?,?)");
$stmt->bind_param("ssi",$fullname,$email,$mobilenumber);
$stmt->execute();
header("Location:thankyou.html");
$stmt->close();
$conn->close();
}
?>
蝴蝶刀刀
RISEBY