我正在尝试让我的 sql 将 html 表单中的信息发布到我的数据库中,但不断得到:
( ! ) SCREAM: Error suppression ignored for
( ! ) Notice: Undefined index: firstname in C:\wamp\www\insert.php on line 29
Call Stack
# Time Memory Function Location
1 0.0005 247624 {main}( ) ..\insert.php:0
我正在使用的代码是:
<form action="insert.php" method="post">
Name: <input type="text" name="firstname">
<input type="submit" value="Submit">
</form>
<?php
// This is the connection to my database
$con = mysql_connect('127.0.0.1', 'shane', 'diamond89');
if (!$con){
die('Could not Connect: ' . mysql_error());
}
// This selects which database i want to connect to
$selected = mysql_select_db("shane",$con);
if (!$con){
die("Could not select data");
}
// This inserts new information to the Database
$name = $_POST['name'];
$query = "INSERT INTO test1 VALUES('id', '$name')";
mysql_query($query) or die('Error' . mysql_error());
// This closes my connection
mysql_close($con)
?>