在表格中插入新的记录。 谁会帮助?
<?php include( config.php ); ?>
<?php
if(!empty($_POST[ forename ]) && !empty($_POST[ surname ]) && !empty($_POST[ email ]) && !empty($_POST[ emailconfirm ]) && !empty($_POST[ password ])) {
if($_POST[ email ] == $_POST[ emailconfirm ]) {
$forename = mysql_real_escape_string($_POST[ forename ]);
$surname = mysql_real_escape_string($_POST[ surname ]);
$email = mysql_real_escape_string($_POST[ email ]);
$password = md5(mysql_real_escape_string($_POST[ password ]));
register();
}
else { $errormessage = "Emails do not match"; }
}
else { $errormessage = "Not all fields filled"; }
function register() {
$check = mysql_query("SELECT * FROM Users WHERE EmailAddress = ".$email." ");
if (mysql_num_rows($check) == 1) {
$errormessage = "Account already exists with the email address provided";
}
else {
$register = mysql_query("INSERT INTO Users (EmailAddress, Password, Forename, Surname) VALUES( ".$email." , ".$password." , ".$forename." , ".$surname." )");
$errormessage = "Account Added";
}
}
?>
我认为,问题在于我的SQL Query声明?