» Smart Phones, Web Design, Google or whatever
Using PHP to redirect to another page
Using PHP to redirect to another page is a common task, especially when you are working with email forms. Fill the form out, process it, then redirect to a “thank you” page:
<?php
header( “Location: http://www.example.com” ) ;
exit;
?>
You can also use variables for the URL like so:
<?php
$destURL = “http://www.example.com”;
header( “Location: ” . $destURL ) ;
exit;
?>
NOTE: The code above has to be processed before any HTML headers, so it needs to be placed above ANY HTML code.
NOTE 2: Watch the code above, depending upon my current CSS in my current theme the single quotes or even double quote may change to fancy quotes which will need to be edited if you cut-n-paste the code.
MORE info available on PHP.net’s header manual page
| Print article | This entry was posted by admin on June 18, 2010 at 3:37 pm, and is filed under Web Design. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |