Redirect problems in a php file.

Discussion in 'PHP' started by douffle, Mar 29, 2008.

  1. #1
    I am working on a site using Dreamweaver which means, of course, that it is .html. I am trying to set up a "Contact Us" form. I downloaded a php script which gives me a Contact Us form that prevents spam and email injection and does not use CAPTCHA. It seems perfect for my needs.

    To implement the script I only need an "include" command in the page.
    I set my Contact Us link in my menu to point to a .php page that contains only the include command.

    <?php include "contact_us.php"; ?> (contact_us.php is the script I downloaded)

    When I click on the Contact Us link in my menu it runs the script fine.
    The problem I am having is that , after filling out the Contact Us form and clicking the "Submit" button, I get a message that says the information was sent successfully, (and in fact it was), but then it just sits there with no way to get back to the home page or a thank you page.

    I know only very little about php programming but I tried altering the code to use a header ("location: index.htm"); but I get the famous "Headers already sent" error.

    I also tried using <meta http-equiv="refresh" content="1;url=http://www.mysite.com/index.htm"> but that didn't work either because I think it has to be used in an html page rather than in a .php script.

    Finally, I tried using this line in the form.

    <input name="redirect" type="hidden" value="index.htm">

    The problem here is that, while it did in fact redirect to the index page, it did so before allowing the form to be filled in. It displays the form for about 2 seconds and then suddenly redirects to the index page. This would be great if it would allow the form to be filled out and redirect only after the "Submit" button was pressed.

    Can anybody offer any assistance with this problem?

    Thanks.
     
    douffle, Mar 29, 2008 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    We need to see the file "contact_us.php" to help you.
     
    Morishani, Mar 29, 2008 IP
  3. c4st

    c4st Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also use the php header() function to change the location.

    
    <?php
    
    header("Location: http://site.com");
    
    ?>
    
    PHP:
     
    c4st, Mar 29, 2008 IP
  4. mds

    mds Active Member

    Messages:
    256
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Are you sure you have no place in the "contact_us.php" file where you are given the option to set a redirect page.



     
    mds, Mar 30, 2008 IP
  5. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Well by seeing your contact_us.php file it will be more easy to rectify the problem.

    Gonzo
     
    Gonzo4u, Mar 30, 2008 IP