I have a select box with dates. When selecting the dates it will display a particular invoice with the date that was selected.Up to this it works fine. What I need is if I go to another page and come back, the select box should be selected with the data that I selected previously.
Use get method. See here. Upon submit, just set your the date on your url redirection then. Then use get method to get the value of the date. Try code below.
$_POST['date'] = $date;
header('location: currentpage.php?date={$date}');
Then when getting back to the form, check if the variable for get method exists, if it exists, check if option is equal to date submitted.
<select name="date">
<option
<?php
if (isset($_GET['date'])) {
if ($_GET['date'] == '12-25-12') { echo "selected"; }
}
?>
>12-25-12</option>
</select>