我已经设置了这个简单的表格,允许您输入您的个人详细信息并将它们存储在数据库中,但它不起作用。
表单 HTML:
<html>
<body>
<form name="test" action="store.php" method="post">
Voornaam: <input type="text" name="first_name"> <br>
Achternaam: <input type="text" name="last_name"> <br>
E-Mail: <input type="text" name="e-mail"> <br>
Telefoon: <input type="text" name="phone"> <br>
Adres: <input type="text" name="address"> <br>
Postcode: <input type="text" name="postal_code"> <br>
Stad: <input type="text" name="city"> <br>
Provincie: <input type="text" name="province"> <br>
Land: <input type="text" name="country"> <br>
<input type="submit" value="Verzenden">
</form>
<body>
</html>
和 PHP:
<?php
/*Database test.
© 2013 Sydcul. All rights reserved.*/
//Please change the following settings:
/*Your database host*/ $host = "localhost";
/*Your database user*/ $user = "root";
/*Your database password*/ $password = "";
//Please don't change the following:
$connection = mysql_connect($host, $user, $password);
mysql_select_db("contact", $connection);
$debug = "INSERT INTO data (first_name, last_name, e-mail, phone, address, postal_code, city, province, country)
VALUES ('" . $_POST["first_name"] . "', '" . $_POST["last_name"] . "', '" . $_POST["e-mail"] . "', '" . $_POST["phone"] . "', '" . $_POST["address"] . "', '" . $_POST["postal_code"] . "', '" . $_POST["city"] . "', '" . $_POST["province"] . "', '" . $_POST["country"] . "')";
mysql_query("INSERT INTO data (first_name, last_name, e-mail, phone, address, postal_code, city, province, country)
VALUES ('" . $_POST["first_name"] . "', '" . $_POST["last_name"] . "', '" . $_POST["e-mail"] . "', '" . $_POST["phone"] . "', '" . $_POST["address"] . "', '" . $_POST["postal_code"] . "', '" . $_POST["city"] . "', '" . $_POST["province"] . "', '" . $_POST["country"] . "')");
echo $debug;
mysql_close($connection);
?>
我相信我曾经让它工作过,但那只是名字。我认为这是我看不到的非常明显的东西,所以请花一些时间来看看它并帮助我。
我把调试的东西放进去调试,它告诉我这个:
INSERT INTO data (first_name, last_name, e-mail, phone, address, postal_code, city, province, country) VALUES ('John', 'Johnson', 'john@johnson.com', '1234567890', 'Street 1', '1234 AB', 'City', 'Province', 'Country')