I have results from a mysqli query returned and displayed on page1. When the user clicks the "register now" link it sends them an HTML form on page2. I need to have certain data (ex: $row[1]) from page1 pass to the html form on page2. I am stuck. Any suggestions are appreciated.
----Here is the UPDATED CODE for trip_1.php :---
<?php
include('includes/connection.php');
if(isset($_POST['clicked'])) {
## you can use GET Method or SESSIONS
## with get
header("Location : reserve-form.php?ID=".$row[1]."");
## or
}
$sql="SELECT * FROM trips WHERE id='1' AND active='1'";
$results=mysqli_query($connection, $sql);
if (mysqli_num_rows($results) < 1) {
echo "<br>We are working on this trip's details.<br><br><h3
style='color:#C8FE2E'>Check back soon!</h3>";
} else {
while($row=mysqli_fetch_array($results)) {
echo"Trip ID: ".$row[1].
"<br>Date: ".$row[3].
"<br>Departs From: ".$row[4].
"<br>Departure Time: ".$row[5]
;
echo "";
}
}
mysqli_close($connection);
?>
<form action="reserve-form.php" method="POST">
<button type="submit" name="clicked">RegisterNow</button>
</form>
...
I NEED .$row[1]. TO PASS TO A FORM FIELD (name=tripID) ON PAGE2
---Here is the UPDATED CODE for reserve-form.php :---
<div class='container' id='new-form'>
<div class='row'>
<div class='col-lg-12'>
<h2>Reserve your Seat</h2>
<hr/>
<form id="reservation_form" action="/insert-form.php" method="post" >
<div class="form-group">
<label>Trip ID#</label>
<input class="form-control" type="text" name="tripID" value="<?php echo
$_GET['ID']; ?>" disabled>
</div>
<div class="form-group">
<label>First Name</label>
<input class="form-control" type="text" name="firstName" required >
</div>
...
$_GET(aka query string) would be the easiest