我的注册码有效,但每次都提交一个副本。例如,如果我尝试提交
Steve Smith stevesmith@gmail.com 123456789
它会在数据库中出现两次,像这样
Steve Smith stevesmith@gmail.com 123456789
Steve Smith stevesmith@gmail.com 123456789
这是我的代码
$failed = "<p class='errormsg'>Registration failed!</p>";
$register = "<p class='errormsg'>Thank you for registering $firstname $lastname</p>";
$adduser = $con->prepare("INSERT INTO basicuserinfo(email, password, firstname, lastname) VALUES(:email, :password, :firstname, :lastname)");
$adduser->bindValue(':email', $email);
$adduser->bindValue(':password', $hash);
$adduser->bindValue(':firstname', $firstname);
$adduser->bindValue(':lastname', $lastname);
$adduser->execute();
if(!$adduser->execute())
{
echo "$failed";
}
else
{
echo "$register";
}
}