SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: form redirect

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form redirect

    instead of keeping people at the same page, i want to redirect someone to a new page after they fill out a form.

    any ideas how to do that?

    here is the code that i have so far:

    <?php
    /**
    * Change the email address to your own.
    *
    * $empty_fields_message and $thankyou_message can be changed
    * if you wish.
    */
    // Change to your own email address
    $your_email = "rkosmic1@aol.com.com";
    // This is what is displayed in the email subject line
    // Change it if you want
    $subject = "Message via your contact form";
    // This is displayed if all the fields are not filled in
    $empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
    // This is displayed when the email has been sent
    $thankyou_message = "<p>Thankyou. Your message has been sent.</p>";
    // You do not need to edit below this line
    $name = stripslashes($_POST['txtName']);
    $email = stripslashes($_POST['txtEmail']);
    $message = stripslashes($_POST['txtMessage']);
    if (!isset($_POST['txtName'])) {
    ?>
    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <p><label for="txtName">Name:</label><br />
    <input type="text" title="Enter your name" name="txtName" /></p>
    <p><label for="txtEmail">Email:</label><br />
    <input type="text" title="Enter your email address" name="txtEmail" /></p>
    <p><label for="txtMessage">Your message:</label><br />
    <textarea title="Enter your message" name="txtMessage"></textarea></p>
    <p><label title="Send your message">
    <input type="submit" value="Send" /></label></p>
    </form>
    <?php
    }
    elseif (empty($name) || empty($email) || empty($message)) {
    echo $empty_fields_message;
    }
    else {
    // Stop the form being used from an external URL
    // Get the referring URL
    $referer = $_SERVER['HTTP_REFERER'];
    // Get the URL of this page
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
    // If the referring URL and the URL of this page don't match then
    // display a message and don't send the email.
    if ($referer != $this_url) {
    echo "You do not have permission to use this script from another URL.";
    exit;
    }
    // The URLs matched so send the email
    mail($your_email, $subject, $message, "From: $name <$email>");
    // Display the thankyou message
    echo $thankyou_message;

    }
    ?>
    thank you for any help =]
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  2. #2
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you can have the form on one page and then have the action="new_page" and then process any information on the new page. If you want to keep the form and processing on the same page
    PHP Code:
    header("location: xxxx"); 
    might fit the bill (where xxxx is the page to send them to).
    Search and compre web hosts
    Website hosting directory


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •