Reputation: 83
i found this link Redirect with Timer in PHP?
i already try this
<meta http-equiv="refresh" content="5;url=http://yourdomain.com"/>
<?php
// wait 5 seconds and redirect :)
echo "<meta http-equiv=\"refresh\" content=\"5;url=http://yourdomain.com\"/>";
?>
Its work but i want redirect back to previous page, any idea? the algorithm is i change page after 5 seconds and want back at previous page after 5 sec to and continue back.. sorry for my bad english
Upvotes: 4
Views: 8271
Reputation: 32740
Use HTTP_REFERER which will give you the page from where you came to the current page.
$_SERVER['HTTP_REFERER']
ref: http://php.net/manual/en/reserved.variables.server.php
<?php
// wait 5 seconds and redirect :)
echo "<meta http-equiv=\"refresh\" content=\"5;url=".$_SERVER['HTTP_REFERER']."\"/>";
?>
Upvotes: 4
Reputation: 27364
You could try redirecting to
sleep(5);
$_SERVER['HTTP_REFERER']
Upvotes: 0
Reputation: 35572
Can Be done with Pure javascript
setTimeout(function(){
window.history.back()
}, 5000);
OR if you want to use php
setTimeout(function(){
window.location = '<?=$_SERVER['HTTP_REFERER'] ?>'
}, 5000);
Upvotes: 1
Reputation: 2540
use window.go(-1);
for details help see http://www.w3schools.com/jsref/met_his_go.asp
Upvotes: 1