Im attempting to create a form so that when the event is selected from the dropdown, when the form on the next page is filled in they both save to the table in the database.
The form:
$party=$_GET['partyName'];
echo "<form method=post action=BookEvent.php>" ;
echo "<table border=0 cellpadding=5>";
echo "<tr><td>First Name </td>";
echo "<td><input type=text name=r_fn size=35></td></tr>";
echo "<tr><td>Last Name </td>";
echo "<td><input type=text name=r_ln size=35></td></tr>";
echo "<tr><td>Tel No </td>";
echo "<td><input type=text name=r_tn size=35></td></tr>";
echo "<tr><td>Email Address </td>";
echo "<td><input type=text name=r_e size=35></td></tr>";
echo "<tr><td>Ticket Quantity</td>";
echo "<td><input type=text name=r_q size=35></td></tr>";
echo "<tr><td><input type=submit value='Request Ticket'></td></tr>";
echo "</table>";
echo "</form>" ;
The 'bookevent page in correlation with the form:
$quantity=$_POST['r_q'];
$name=$_POST['r_fn'];
$sname=$_POST['r_ln'];
$tel=$_POST['r_tn'];
$email=$_POST['r_e'];
$party=$_GET['partyName'];
if (!$name or !$sname or !$tel or !$email or !$quantity)
{
echo "<p>Your form is incomplete ";
echo "<br>Please fill in details ";
include("footlayout.html");
}
else
{
$SQL="insert into Bookings(customerFName, customerSName, customerTelNo, customerEmail, tickets) values ('".$name."','".$sname."','".$tel."','".$email."','".$quantity."')";
$exeSQL=mysql_query($SQL);
echo"Thank you for booking ";
}
$ASQL="select Quantity from PARTY where Name='$party'";
$exeASQL=mysql_query($SQL) or die (mysql_error());
$array=mysql_fetch_array($exeASQL);
$quantity=$array['r_q'];
if ($ticket>$quantity)
{
echo"Sorry There are only:" .$quantity;
include("footlayout.html");
exit;
}
echo"Thank you for booking tickets to";
echo $party;
My issue is that I am trying to separate the statements after the first 'if' because if all the records are entered correctly, The page echoes both messages the 'Thank you for booking tickets to' and the 'Sorry there are only' also both variables $quantity and $party don't show their values.
Please help me out, I'm new to coding and attempting to teach myself. I would be extremely grateful!