I have multiple forms that I am trying to insert data from into MySql. Each form has a different table associated with that information. I am using an insert.php file to insert the data. The first form works great. However when I add any other variables to the initial file it errors out. This is my insert file:
<?php # NAME OF PROGRAM GOES HERE
require_once 'config.php';
// Get values from form
$Fname = $_POST['first_name'];
$email = $_POST['email'];
// Insert data into mysql
$sql="INSERT INTO entry (first_name, email)
VALUES ('$Fname', '$email')";
$result = mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful Entry";
}
else {
echo "ERROR";
}
mysql_close();
?>
This is the first form:
<form action="insert.php" method="post" name="admin" onSubmit="return validateForm()">
<p>Please enter First Name <input type="text" name="first_name" required="required"/>
<p>Please enter your Email<input type="text" name="email" required="required" ><br />
<input type="submit" name="submit" value="Submit" />
</form>
The second form is:
<form action="insert.php" method="post" onSubmit="return validateForm()">
<p>Favorite Winery Name <input type="text" name="fav_winery" /> <br />
<p>Favorite White Wine<input type="type" name="fav_white" /> <br />
<p>Favorite Red Wine <input type="type" name="fav_red" /> <br /><br />
<input type="submit" name="submit" value="Submit" />
</form>
How do I INSERT the information from the second form into another table already created?