I have a main page including a header page to make editing the header across all pages a quicker process. The issue I am running into is that this header has search option on it, and I want the search term to be saved in a session variable. It works fine if the header is on the page itself and not on an included page, but as soon as I put the header into its own file the search function stops working as intended.
this is simply the include code:
<?php
if (!isset($_SESSION)) {
session_start();
}
$redirectAction = $_SERVER['PHP_SELF'];
?>
<html>
<body>
<?php include 'http://www.saxon564.com/tclusa/header.php'; ?>
</body>
</html>
Here is the header.php code:
<?php
if (!isset($_SESSION)) {
session_start();
}
if ((isset($_POST["search"])) && ($_POST["search"] == "1")) {
$_SESSION['query'] = $_POST['query'];
}
?>
<html>
<body>
<form action="<?php echo $redirectAction; ?>" method="POST">
<input type="text" name="query" id="query" placeholder="Search" size="20" value="<?php echo $_SESSION['query']; ?>" />
<input type="hidden" name="search" id="search" value="1" />
<input type="submit" class="sbmt" value="Search" />
</form>
</body>
</html>
What happens is when I submit the search, the page reloads, but the search data was not saved. I am probably missing something important, but I am getting no where with this. Does anyone have a thought as to what the issue is, or if this just isn't possible?