Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirection

Status
Not open for further replies.

SmileeTiger

Programmer
Mar 13, 2000
200
US
Umm how the heck do I do redirection in PHP?
I want to foward users to different pages depending on input into a text box but I have no idea how redirection works..
Cory
 
You should NOT use javascript
use
Code:
header("Location: redirect.html");

however, you should use the header function before the HMTL headers are sent. So make youre page look like this

Code:
<?php
switch ($var)
{
  case &quot;a&quot;:
    header(&quot;Location: a.html&quot;);
    exit;
  case &quot;b&quot;:
    header(&quot;Location: b.html&quot;);
    exit;
  case &quot;c&quot;:
    header(&quot;Location: c.html&quot;);
    exit;
}
/* or 
    header(&quot;Location: $var&quot;);
   or
    header(&quot;Location: $var.html&quot;);
*/
?>
<html>
<head>...</head>
<body>
error don't know page <? echo $var ?>
</body>
</html>
 
Thanks! That helped lots. One just has to remember not to print any text first!


Cory
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top