Hello I have problem that I’m loosing $_POST['id'] value from select tag after clicking on href. Well the code is here:
$page = 1;
if (isset($_POST['id'])){
$id = $_POST['id'];
}
echo $id[0];
?>
<ul>
<li><a href="?show=all">Show All</a></li>
<li><a href="?show=submitted">Show Submitted</a></li>
<li><a href="?show=pending">Show Pending</a></li>
<li><a href="?show=not">Show Not Submitted</a></li>
</ul>
<form action="" method="post">
<select name="id">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
<option value="5">five</option>
<option value="6">six</option>
<option value="7">seven</option>
<option value="8">eight</option>
</select>
<input type="submit" name="mode" value="Select" />
</form>
The idea is that after when i’ve selected some value from selected field I need to keep that value in variable and also I need for further filtering SQL query which works after <a href="">.
At the moment after submitting form I get select value, but after further filtering pressing any of <a href=""> links $_POST value dissapears… how can I keep that value after pressing on any link?
Link click always produce GET request and does not submit a form by default. So you must pass it as a query parameter:
And, of course, you will need to take it from
$_GETin such case. But as you can get it from both$_POSTand$_GETyou may use$_REQUESThere: