I am trying to make it so when the page reloads it redirects me with the same $_GET parameters as the previous page. Right now I am trying to use header to achieve this, but when I submit my form the variable $id is blank.
HTML Form
<form action = "." method ="post">
<input type = "text" name = "username">
<textarea name = "comments"></textarea>
<input type = "hidden" name = "action" value = "posts">
<input type = "submit" name = "submit" value = "Add Post">
</form>
Redirect Script
if ( empty( $_GET ) && !empty($_POST) ){
if($action == 'posts'){
if(!isset($_GET['thread'])){
$id = $_GET['thread'];
header('Location: ' . $_SERVER['REQUEST_URI'] .'?thread='.$id);
}
}
Thanks for anyone who replies!