嗨,我不明白为什么这段代码没有将 html 文本字段中的数据插入到我的实际数据库中。我正在尝试仅使用 First_Name 对其进行采样。
无论如何HTML代码如下:
<form action="Proform.php" name="Myform" method="post">
<input type ="hidden" value="1" name="check_submit" />
Please Enter First Name: <input type ="text" name="First_Name" /> <br />
Please Enter Second Name: <input type ="text" name="Second_Name" /><br />
Please Enter Email Address: <input type ="text" name="Email_Address" /><br />
Please Enter A Password: <input type="password" name="Password" /><br />
<input type ="submit" name"Submit" /><br />
</form>
php和MYSQL如下:
<?php
$dbname='ecig';
$dbhost='localhost';
$dbpass='password';
$dbuser='eciguser';
$dbhandle = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$selected = mysql_select_db("ecig",$dbhandle)
or die("Could not select examples");
$res=mysql_query("INSERT INTO Persons (First_Name, Second_Name) VALUES ('$_POST[First_Name]')");
if (array_key_exists ('check_submit', $_POST ))
echo "Your Name is : {$_POST['First_Name']}<br />";
echo "Your Second Name is : {$_POST['Second_Name']}<br />";
echo "Your Email Address is : {$_POST['Email_Address']}<br />";
echo "Your Password Is : {$_POST['Password']}<br />";
?>
它一定与这行代码有关,但我无法发现它.. 你们中的任何人都发现出了什么问题吗?
$res=mysql_query("INSERT INTO Persons (First_Name, Second_Name) VALUES ('$_POST[First_Name]')");
任何帮助将非常感激。谢谢 。