Redirect header : header « HTML « PHP






Redirect header

 
<?php 
  $location = $_POST['location'];
  $self = $_SERVER['PHP_SELF'];

  if( $location != null )
  {
    header( "Location:$location") ;
    exit();
  }
?>



<html>

 <head>
  <title>Redirect</title>
 </head>

 <body>
  Choose a site to visit:
  <form action = "<?php $self ?>" method = "post">
   <select name = "location">
   <option value = "http://www.google.com">Google</option>
   <option value = "http://www.ebay.com">Ebay</option>
   </select>
   <input type = "submit" name = "submit" value = "Go">
  </form>

 </body>

</html>
  
  








Related examples in the same category

1.Changing the page type to CSV
2.Changing the page type to XML
3.Setting a Cookie Using the header() Function
4.Logged In with cookie
5.Forcing File "Save As" Downloads
6.Good and bad Location headers
7.If a User Is Not Logged in, the Login Form Is Loaded
8.Mime types
9.Using header() to Send Raw Headers
10.Setting character encoding
11.Sending an XML response
12.Sending Content Types Other Than HTML
13.Reading Queued Headers
14.Redirecting with query string variables