I am trying to take the results from my input form and sent the results to two different tables.
In my first table I have the following columns: PersonID, StudentID, FirstName, LastName,
In my second table I have the following columns: EventID, EventName
In my third linking table I have the following columns: PersonID, EventID and Time
From my form, I want to take all the inputs and distribute them across all three tables, but I'm not sure how to do this.
Here is my PHP:
<form action="enter.php" method="post">
<h2>Student ID: </h2>
<input name="StudentID"/>
<h2>First Name: </h2>
<input name="FirstName"/>
<h2>Last Name: </h2>
<input name="LastName"/>
<h2>Event Name: </h2>
<input name="EventName"/>
<h2>Event Time: </h2>
<input name="EventTime"/>
<br /><input type="submit" name="submit" value="Enter Results for Person"/>
</form>
<?php
if(!mysqli_select_db($dbcon,'NAMEOFDATABASE')) {
echo 'Database not selected!';
}
if(isset($_POST['submit'])){
$StudentID = $_POST['StudentID'];
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$sql = "INSERT INTO Persons (StudentID, FirstName, LastName) VALUES ('$StudentID','$FirstName', '$LastName')";
if(!mysqli_query($dbcon,$sql)) {
echo 'Person was NOT inserted into Persons Table Succesfully';
} else {
echo 'Person was inserted into Persons Table Succesfully';
}
}
?>
Any help is appreciated :)