Web Hosting Talk







View Full Version : go to another page


slice16
09-08-2004, 06:16 PM
once i haev verified an account from a database... if the username and password are correct, how will i send the user to a new area? i have the code for the user verification sorted....

bhanson
09-08-2004, 06:30 PM
You can use the function header() in php to do it at a server-side level, or you can use JavaScript. (That was, assuming you're using PHP, if not the JavaScript below will still work, just strip the PHP codes.)

Here's a function that I use in one of my scripts.


function redirect($to)
{

$javascript .= "
<script language=\"javascript\">
setTimeout(\"window.location = ('$to')\",2000)
</script>
";

return $javascript;

}


If you use the JavaScript method, be sure to have a real text link also that points to where the redirect would have gone, incase they have JavaScript disabled.

ilyash
09-09-2004, 12:35 AM
you can use a php include
or an iframe or a http meta refresh

pphillips
09-09-2004, 03:37 AM
You can send redirect headers to their browser (in PHP) by using the following:

header("Location: page.php");

Just make sure you haven't echoed anything to the browser previous to sending the header.