I need to redirect my page to another, but I can't use the header
function, is there any other way to do it?
What a I need to do is something like this:
if (test){
---do something---
redirect
} else {
return false
}
Thanks
I need to redirect my page to another, but I can't use the header
function, is there any other way to do it?
What a I need to do is something like this:
if (test){
---do something---
redirect
} else {
return false
}
Thanks
if (test){
---do something---
die("<script>location.href = 'http://www.google.com'</script>");
} else {
return false;
}
A meta-redirect
if (test){
//do something
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=yourpage.php">';//This causes the browser to open the new page after 0 seconds, i.e immediately.
} else {
return false;
}
if (test){
echo "<script type='text/javascript'>
window.onload = function () { top.location.href = '" . $url . "/page.php#contact'; };
</script>";
} else {
return false
}
if (test){
---do something---
$URL="http://yourwebsite.com/";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
} else {
return false;
}
If you're wondering that why I have used both Meta tag and JavaScript to Redirect, then the answer is very simple.
If JavaScript is Disabled in the Browser, then meta tag will redirect the page.