I have 2 pages and there is a form in each page. the first form accepts user input and preview it on the second page (hidden form elements). on the second form the user clicks the submit button and it insert that data into mysql.
The problem, the second page insert data into mysql once I get to that page via the form POST method and I get empty fields in the database and the isset function for the form submit button not working.
First page (form):
<html>
<body>
<form action="review.php" method="post">
Name: <input type="text" name="name"><br>
Age: <input type="text" name="age"><br>
<input type="button" name="submit" value="submit">
</form>
</body>
</html>
I get to the second page for review called review.php with this code:
<?php
if (isset($_POST['submit'])) {
// Mysql insert statment
echo "Form has been submitted";
}
?>
<html>
<body>
<form action="review.php" method="post">
Name: <input type="hidden" name="name"><p><?php echo $_POST['name']; ?></p><br>
Age: <input type="hidden" name="age"><p><?php echo $_POST['age']; ?></p><br>
<input type="submit" name="submit">
</form>
</body>
</html>
Once I click on the review button from the first form, it inserts that into mysql, so the isset function on the review.php is not working.
name="submit".