I also have a string stored in a session variable but can't figure out how to get it back out again...
THIS CODE IS PAGE 1.
<form action="page1.php" method="post" id="register-form" novalidate="novalidate">
<b>Postcode:</b> <input type="text" name="search" /> (required)<br />
<?php
@session_start();
if (empty($_POST['search']) && isset($_POST['submit'])){
echo'Please enter postcode i.e. ZZZZ';
}
?><br />
<p><input type="submit" name="submit" value="Search"></p><br />
</form>
</div>
</body>
<?php
/* Check all form inputs using check_input function */
$search = $_POST['search'];
/*Assign variables to session variables*/
$_SESSION['search'] = $search;
header ("Location: http://www.example.com/page2.php");
exit();
?>
I run the code above and then when the user submits, there is a page redirect to PAGE 2. The session variable 'search', which contains a postcode string, is carried over to page 2, where I'm hoping to use the string variable as part of a query to retrieve some information from a database. I figure I need to convert it back into a string so it can be used to retrieve data from database... I just don't know how...
Can someone please help!?