在我的网站上我有一个注册表。用户只需输入电子邮件,密码并重新输入密码即可。PHP不提交用户的详细信息到数据库?
但是,即使填写了所有字段,我仍然收到一个错误,表示我没有填写表格。我不明白我做错了什么(PHP相对较新)
请注意我没有尝试清理用户输入,因此我知道我的代码将容易受到SQL注入!
<?php
include("database.php");
include("requirements.php");
if(isset($_POST['register'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$confpassword = $_POST['confpassword'];
}
if(isset($password) && isset($email) && isset($confpassword)){
if($password != '' && $email != '' && $confpassword != ''){
if($password == $confpassword){
if(strlen($password) <= 20 && strlen($password) >= 6){
if(strlen($email) > 6){
$hash = password_hash($password, PASSWORD_DEFAULT);
$insert_user = mysqli_query($con, "INSERT INTO users (email, password, salt) VALUES ('".$email."', '".$password."', '".$salt."')");
if($insert_user)
{
echo "Thank you for registering, you can now login to your account and create a listing.";
}
else
{
echo "Sorry there was an error - please try again later. If the issue continues please contact support.";
}
}
else
{
echo "You need to insert an email.";
}
}
else
{
echo "The entered email address needs to be above 6 characters.";
}
}
else
{
echo "The password must be between 6 and 20 characters long.";
}
}
else
{
echo "The two passwords you have entered do not match.";
}
}
else
{
echo "You have not inserted all of the required fields that were needed.";
}
它只是跳到最后说“你没有插入所有需要的字段。”甚至不尝试查询数据库。
database.php中只是有数据库信息(表,密码等)
感谢您的连接!
原来,这是HTML - 在我的表单中,我的“Value =”注册“”在我的按钮上,而不是“占位符=”注册“”......菜鸟错误。多谢你们! – PublicDisplayName
不客气;) – Lemurantin