我正在尝试制作一个简单的 RSVP 程序,用户只需输入他们的名字和姓氏,然后单击是或否。然后将信息带入数据库。我被困在用户可以输入名字和姓氏并单击“是”或“否”的位置,但它没有显示在数据库中。这是我到目前为止所拥有的。任何帮助将不胜感激。我仍然是 php 的菜鸟。我也在为我的数据库使用 xampp。谢谢
这是上半场
<H1><div align="center">RSVP</div></H1>
<H3>Enter in the information that is requried</H3>
<form method ="POST" action = "RSVP.php">
Please type in your first name</br>
<input type = "text" name="fname"/></br>
Please type in your last name</br>
<input type = "text" name="lname"/>
</br></br></br></br>
<H2>Will you be attending?</h2>
<input type="radio" name="yorn" value="Yes">Yes
<input type="radio" name="yorn" value="No">No</br>
<input type="submit" value="Submit">
</form>
这是php的一半
<?php
if(empty($_POST['fname']) || empty($_POST['lname']))
print "Please type in BOTH first name and last name";
else{
$DBConnect = @mysql_connect("localhost", "Jordan", "bigboy");
if ($DBConnect === FALSE){
print "<p>Unable to connect to the database server.<p>". "<p>Error code "
.mysql_errno(). ": ". mysql_error() . "</p>";
}else{
$DBName = "jdatabase";
mysql_select_db("jdatabase") or die(mysql_error());
$TableName = "RSVP";
$firstname = $_POST['fname'];
$lastname = $_POST['lname'];
$YorN = $_POST['yorn'];
$SQLsting = "INSERT INTO '$TableName' VALUES(NULL,
'$firstname','$lastname','$YorN')";
$QueryResult = @mysql_connect($SQLsting, $DBConnect);
}if ($QueryResult === FALSE){
print "<p>Unable to execute query.<p>". "<p>Error code "
.mysql_errno($DBConnect). ": ". mysql_error($DBConnect) . "</p>";
}else{
print "Thank You for RSVP";
}
mysql_close($DBConnect);
}
?>