無法將新記錄插入表中。有人在乎幫忙嗎?無法使用PHP插入到MySQL表中
<?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";
}
}
?>
我認爲問題出在MySQL查詢語句中?
您是否收到錯誤消息?如果是這樣,那是什麼? – 2010-08-08 02:25:30
Aaron W .:沒有錯誤信息,它將空格插入表中 – ritch 2010-08-08 02:27:01