Tedd's Redirect Example

This is Exercise 2 on Page 266 (end of Chapter 9) in "Beginning PHP 5.3".

Redirect:



 

CODE FOLLOWS

<?php

    error_reporting
(E_ALL);    // set error reporting to all
    
$self basename($_SERVER['SCRIPT_NAME']);
    
$where = isset($_POST['where']) ? $_POST['where'] : null;
    
$step = isset($_POST['step']) ? $_POST['step'] : 0;

    if (
$step == 1)
        {
        
header("Location:$where");
        exit(
0);
        }

    include(
'includes/header.php');
?>
    <h1>
        Tedd's Redirect Example
    </h1>

    <p>
        This is Exercise 2 on Page 266 (end of Chapter 9) in "Beginning PHP 5.3".
    </p>

    <form action="<?php echo($self); ?>" method="post">
        <fieldset>
            <legend>Redirect:</legend>
            <input type="hidden" name="step" value="1">
            <label for="amazon.com">Amazon.com</label>
            <input type="radio" id="amazon.com" name="where" value="http://amazon.com" checked> <br>
            <label for="amazon.ca">Amazon.ca</label>
            <input type="radio" id="amazon.ca" name="where" value="http://amazon.ca"> <br>
            <label for="amazon.com.uk">Amazon.com.uk</label>
            <input type="radio" id="amazon.com.uk" name="where" value="http://amazon.co.uk"> <br><br>
            <input type="submit" name="submit" value="Submit">
        </fieldset>

    </form>

<?php
    
include('includes/footer.php');
?>