I am trying to place a variable in a url and submit the form automatically
I am doing a mysql select, and based on the results I need to do as explained above.
PHP
<?php
$stmt = $conn->prepare("SELECT prime_ID,
FROM School
WHERE Date = (CURDATE() - INTERVAL 2 DAY)");
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$SchoolId = $row["prime_ID"];
header("Location:../SchoolList.php?school=" . $SchoolId . "&Submit=Submit");
}
?>
HTML of SchoolList.php
$shoolid = $_GET['school'];
<form method="POST" action="test.php">
<input type="text" name="school" id="school" value="<?php echo $shoolid ?>">
<br>
<input type="Submit" name="Submit" id="Submit" value="Submit">
</form>
The SELECT
works but the form does not submit. The variable is also visible in the next page. Although the form redirect to SchoolList.php
, the URL looks like this SchoolList.php?school=45&Submit=Submit
Why does it not submit SchoolList.php
?