I am working on PHP. I want to redirect the page after entering the last page I want to visit, but I am still here after 5 hours, and I still do not. This is a diagram, I have 3 php files.
newest.php (before login),
signin.php (before login),
thread.php (after login).
I use cookies for this redirect. First I went to newest.php, then I clicked the button (go to thread.php). Then thread.php saw that you did not have loggin yet, and then redirected to signin.php. After I filled out the syntax form, I clicked the submit button (signin.php), then I put in signin.php (nowhere to go) even after I log in, I need to go to thread.php automatically.
this is my code in newest.php and thread.php (not in signin.php):
$coopage='coopage';
$current_page='http://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
setcookie($coopage, $current_page,time()+86400,'/');
send button to newest.php (it goes to thread.php):
echo "<center><button onclick=\"window.location='/thread/form'\">add new thread</button></center>";
signin.php( , , ) ( ):
if(isset($_COOKIE[$coopage])){
$url=$_COOKIE[$coopage];
unset($_COOKIE[$coopage]);
header('location:'.$url);
}
note: signin.php cookie cookie, ? , 2 cookie ? cookie ( ).
$cooval2='juna';
setcookie($coousername, $cooval2, time() + (3600 * 24 * 365), "/"); // 1 year