faqts : Computers : Programming : Languages : PHP : Common Problems : Redirects

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 13 people (77%) answered Yes
Recently 6 of 8 people (75%) answered Yes

Entry

How can I redirect the user to a relevant page after executing PHP code?

Jan 19th, 2000 18:45
Chris Kings-Lynne, Rio Bautista, Les Cole, Nathan Wallace, fsockopen()


A much better way is to have a php script like this...
<?php
  // This script takes a zipcode and redirectst the visitor
  // to a relevant website.
  $url = getURL($zipcode);  // This is implemented somehow...
  Header("Location: $url");
?>
The location header will simply redirect the visitor's browser.  It is 
the perfect way to do this.
Old Answer
----------
I can think of 3 ways:
1.  Crude way:  make a php3 that displays a "click-here-to-continue" 
page that automatically refreshes to the site of the store.
2.  Using JavaScript w/ PHP: something like this 
<?php
  print '
<html>
<script language="JavaScript">
window.location.href = "'. $yourstoresURL .'"
</script>';
?>
3.  fsockopen() way:  use fsockopen() passing the URL of the store, 
read from that socket and display the results.  The example provided in 
the manual should give you enough ideas for this.