I am trying to make a simple RSVP program where I the user just type in their first and last name and then clicks yes or no. The information is then taken to the database. I am stuck where the user can type in the first and last name and click yes or no but it does not show up in the database. Here is what I have so far. Any help will be appreciated thanks. I am still a noob at php. I am also using xampp for my database. Thanks
This is the first half
<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>
This is the php half
<?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);
}
?>