I have a search form on every page that goes to a certain page to show the results:
- Code: Select all
<?php require_once('lib/search_box.php'); ?>
The issue is that when I'm already on the results page and re-submit the form the page fails to load:
PHP:
- Code: Select all
if(isset($_POST['spsearch'])) {
$_SESSION['STCode'] = $_POST['STCode'];
$_SESSION['STSCCode'] = $_POST['STSCCode'];
$_SESSION['OrderBy'] = $_POST['OrderBy'];
$_SESSION['PCode'] = strtoupper(str_replace(" ", "", $_POST['PCode']));
$_SESSION['Distance'] = $_POST['Distance'];
$_SESSION['BName'] = $_POST['BName'];
$_SESSION['City'] = $_POST['City'];
$_SESSION['County'] = $_POST['County'];
$_SESSION['SrchPage'] = "0";
header("Location: my_results_page.php");
exit;
} else {
if($_SERVER['REQUEST_URI'] != "") {
$action = htmlentities($_SERVER['REQUEST_URI']);
} else {
$action = htmlentities($_SERVER['PHP_SELF']);
}
FORM ACTION:
- Code: Select all
<form id="search_for_sp" method="post" action="<?php echo htmlentities($action); ?>" onchange="toggle()">
Any ideas? I think it might be because it's sending the user to the page the form is included on already. Is there a way around this please anyone?
As an additional note, when the page fails, if I click refresh - or highlight the url in the browser bar and click return - the page loads with the new content.
Kindest regards
Glynn

