I am trying to create an account registration form in PHP. I have connected it to my MySQL database, but after I try to sign up with the form I get the error that is in the title.
if(isset ($_POST['submit']))
{
include( 'connection.php' );
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
if(empty($username) || empty($email) || empty($password))
{
echo 'Please check the required fields.';
}
elseif(!filter_var($email,FILTER_VALIDATE_EMAIL))
{
echo 'Please enter a correct email address.';
}
else
{
$password = md5($password);
$sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password',now())") or die(mysql_error());
if($sql)
{
echo 'Successfully submitted.';
}
}
}
解决方案
3 columns:
$sql = mysql_query("INSERT INTO users (email,username,password)
4 values:
VALUES ('$email','$username','$password',now())") ...