我似乎遇到了一些PHP问题。它从HTML页面获取数据,然后将其添加到MySQL数据库,但信息不会出现。
<?php
// Variables
$email = $_POST["email"];
$username = $_POST["username"];
$password = $_POST["password"];
$passwordconfirmation = $_POST["passwordconfirmation"];
// Failure
if ($password !== $passwordconfirmation)
{
echo "The password fields do not match. Please enter your password again.";
}
// Success
else
{
$connection = mysqli_connect("*****.com", "*****", "*****", "charlesfriessdatabase"); // Connect
// Error Message
if (!$connection)
{
die ("Error");
}
mysqli_query("INSERT INTO accounts (email, username, password) VALUES ($email, $username, $password)"); // Inserter
mysqli_close($connection); // Connection Closer
echo "You have successfully signed up! Please check your email to confirm your account."; // Success Message
}
?>
答案 0 :(得分:3)
在变量中需要放置'
尝试添加此字符并告诉我们。
这应该是:
mysqli_query("INSERT INTO accounts (email, username, password) VALUES ('$email', '$username', '$password')");
答案 1 :(得分:1)
if ($password !== $passwordconfirmation)
更改为
if ($password != $passwordconfirmation)
答案 2 :(得分:0)
您遇到语法错误。此
if ($password !== $passwordconfirmation)
应该是
if ($password != $passwordconfirmation)
只有一个=
答案 3 :(得分:0)
尝试!=而不是!==密码比较。
也许
if (!$connection) {
die('Connect Error: ' . mysqli_connect_errno());
}