我已经启动了这个,只有名称和电子邮件字段,查询确实成功运行,因为它工作正常我添加了更多字段更新代码。但这次它没有用,带我到同一页面,没有给我任何错误。
<?php
require "config.php";
if(isset($_POST['name']) && isset($_POST['address']) && isset($_POST['city']) && isset($_POST['postalcode']) && isset($_POST['country']) && isset($_POST['email']) && isset($_POST['datepicker']) && isset($_POST['phone'])) {
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$postalcode = $_POST['postalcode'];
$country = $_POST['country'];
$email = $_POST['email'];
$birthday = $_POST['datepicker'];
$phone = $_POST['phone'];
$IP = $_SERVER['REMOTE_ADDR'];
$date = date('Y-m-d H:i:s');
if(!empty($name) && !empty($address) && !empty($city) && !empty($postalcode) && !empty($country) && !empty($email) && !empty($birthday) && !empty($phone)) {
$query = "INSERT INTO `users` (name, address, city, postalcode, country, email, birthday, phone, IP, date) VALUES ('$name', '$address', '$city', '$postalcode', '$country', '$email', '$birthday' '$phone', '$IP', '$date')";
$result = mysql_query($query);
if($result) {
echo "Registered Successfully";
} else {
echo "You're required to fill in all the fields.";
}
}
}
?>
<form action="join.php" method="POST">
<p> <label for="name">Name:</label>
<input type="text" name="name" > </p>
<p> <label for="address">Address:</label>
<input type="text" name="address" > </p>
<p> <label for="city">City:</label>
<input type="text" name="city" > </p>
<p> <label for="postalcode">Postal Code:</label>
<input type="text" name="postalcode" > </p>
<p> <label for="country">Country:</label>
<input type="text" name="country" > </p>
<p> <label for="email">Email:</label>
<input type="text" name="email" > </p>
<p> <label for="birthday">Birthday:</label>
<input type="text" name="birthday" > </p>
<p> <label for="phone">Phone:</label>
<input type="text" name="phone" > </p>
<input type="submit" value="order">
</form>
我已在此处粘贴代码:http://codepad.org/BuRFV276
答案 0 :(得分:2)
您没有任何名为&#39; datepicker&#39;。
的字段只需将所有$_POST['datepicker']
替换为$_POST['birthday']
并且插入查询中存在语法错误。您错过了$ birthday
和$ phone
不要使用mysql_*
因为所有mysql_*
函数都已弃用,而是使用mysqli
或PDO
。
答案 1 :(得分:2)
您在$birthday
和$phone
变量之间错过了逗号 -
'$birthday' '$phone',
// ^ right there