I have 2 pages in php. The 1st page includes a search form. All the results of this form I want to save them into a session. In the 2nd page I want a link so that if in search form someone types something, by clicking a link in the 2nd page to execute it. This is what I have done so far:
1st page
<form method="POST" name="go" action="search_form_all.php" >
<input name="value" type="text" id="search_form_1" size="65" autocomplete="off" placeholder=" Search People ..." style="" />
<input type="submit" value="" name="submit" style="background:url('img/arrow.png') no-repeat; width:23px; height:23px; cursor:pointer; border:none; "/>
</form>
<?php
// starting the session
session_start();
if (isset($_POST['Submit'])) {
$_SESSION['value'] = $_POST['value'];
}
?>
2nd page
<?php
echo"<a href='search_form_all.php'>click to view results";
?>
I don't know what is the name on your first page, but you're form's action is on *search_form_all.php*. Make sure that you are doing this
$_SESSION['value'] = $_POST['value'];
in that page. Otherwise, there is no data to insert into your SESSION variable.
If you want you're form to be on the same page with
$_SESSION['value'] = $_POST['value'];
you should use
<form method="POST" name="go" action="" >
Also, I don't know if that's a problem, but I usually use session_start() on top of my page to be sure there aren't other headers before.
Hope it helps!