I am attempting to write a program that will take information from an html form, and upload it to a MySQL database that exists on my local host(using XAMPP). To do this, I have used HTML to create a form that will take in the data to be inserted to the database, like this:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="styles/main.css">
<meta charset="utf-8">
<title>Presentation Registration</title>
<script type="text/javascript">
function Submit()
{
// I put input validation stuff here, but left it out to simplify code for reading
document.getElementById("myForm").submit();
}
</script>
</head>
<body>
<form id="myForm" action="actionPage.php" method="post">
<TABLE>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot1" value="Slot1">12/9/15, 6:00 PM – 7:00 PM</TD>
<TD>
<?php
$con = mysqli_connect('localhost','username','password', 'myDB');
$query = "SELECT * FROM reserve";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot2" value="Slot2">12/9/15, 7:00 PM – 8:00 PM</TD>
<TD><?php
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot3" value="Slot3">12/9/15, 8:00 PM – 9:00 PM</TD>
<TD><?php
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot4" value="Slot4">12/10/15, 6:00 PM – 7:00 PM</TD>
<TD><?php
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot5" value="Slot5">12/10/15, 7:00 PM – 8:00 PM</TD>
<TD><?php
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
<TR>
<TD><input type="radio" name="TimeSlot" class="TimeSlot" id="Slot6" value="Slot6">12/10/15, 8:00 PM – 9:00 PM</TD>
<TD><?php
$row = mysqli_fetch_array($result);
echo $row["Open Seats"]." ";
?>
Seats Remaining</TD>
</TR>
</TABLE>
<button type="button">Student List</button>
<TABLE>
<TR>
<TD>UMID </TD>
<TD><input type="text" class="inputText" id="UMID" name="UMID"></TD>
</TR>
<TR>
<TD>First Name </TD>
<TD><input type="text" class="inputText" id="fName" name="fName"></TD>
</TR>
<TR>
<TD>Last Name </TD>
<TD><input type="text" class="inputText" id="lName" name="lName"></TD>
</TR>
<TR>
<TD>Project Title </TD>
<TD><input type="text" class="inputText" id="projectTitle" name="projectTitle"></TD>
</TR>
<TR>
<TD>E-Mail </TD>
<TD><input type="text" class="inputText" id="email" name="email"></TD>
</TR>
<TR>
<TD>Phone Number </TD>
<TD><input type="text" class="inputText" id="phone" name="phone"></TD>
</TR>
</TABLE>
<button type="button" OnClick=Submit()>Submit</button>
</form>
</body>
</html>
As seen in the code, I use an action tag on the submit function to trigger "actionPage.php" to run. The code inside of that program is shown below:
<?php
$con = mysqli_connect('localhost','username','password', 'myDB');
$umid = $_POST['UMID'];
$fName = $_POST['fName'];
$lName = $_POST['lName'];
$projTitle = $_POST['projectTitle'];
$eMail = $_POST['email'];
$phone = $_POST['phone'];
$slotID = "1";
$query = "INSERT INTO student (UMID, fName, lName, projTitle, e-Mail, phone#, SlotID) VALUES ($umid, $fName, $lName, $projTitle, $eMail, $phone, $slotID)";
$result = mysqli_query($con, $query);
echo "Database Insertion Complete";
?>
All of this connects to a database with two tables, student and reserve. When I run the code and input the information, actionPage.php triggers, and runs through all the code, including the echo statement at the end. However, the student table is not updated when I look in XAMPP. Is there something wrong with my code, or should I look for other issues?