+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP redirect based on form input - but doesn't work. Defaults to generic Thank You

  1. #1
    Join Date
    Oct 2006
    Posts
    11

    Question PHP redirect based on form input - but doesn't work. Defaults to generic Thank You

    I hope someone can help. I'm researched out and getting frusterated.

    I have a form setup with various info that is emailed to me, via post. What I need to do is, upon submission, redirect the user to one of two pages, based on a select box in the form. I don't want them to automatically jump after the selection, but rather when they hit submit. Here's what I've added to my header


    <?php
    if($_REQUEST['redirect']){
    print "
    <meta http-equiv='refresh' content='0; url={$_REQUEST[redirect]}'>";
    }
    ?>

    and here's what I have in the form itself...
    <FORM METHOD="POST" ACTION="http://www.mysite.com/cgi/formtest1.php">
    <input type=
    "hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER">
    <input type=hidden name=
    "subject" value="Contact">
    <input type=
    "hidden" name="recipients" value="support@mysite.com/">
    <input type=hidden name=
    "bad_url" value="http://www.mysite.com/oops.html">
    <input type=hidden name=
    "required" value="realname, email, state, address, city, zip, phone, redirect">
    <tr><td width="100"><b><font color="#ff0000" size="3">*Choose One</font></b></td><td><select name="redirect"><option value="http://www.mysite.com/folder/page2.html">Page 2</option><option value="http://www.mysite.com/folder/page1.html">Page 1</option>
    </select></td></tr>
    </table></blockquote>
    <hr color=
    "#9CCEDA" width="85%" align=center>
    <center><INPUT TYPE="IMAGE" src="submitbutton.gif" width="225" height="38" alt="Click here to submit the form!" border="0"></center><br></form>

    Now, I removed some fluff in the form, like tables etc, for the purpose of this thread so it doesn't really look right, I realize that, but it's correct form wise. The form as is, works perfectly, except the redirect. I get the email as admin, and I get the generic thank you page, as a user. No redirect at all.

    Now, some might suggest I use the good url and/or bad url, and that would be perfectly fine if I didn't need the redirect to be based on the form selection. I have to figure out how to bypass that thank you page. I really think what I already have would work, if it wasn't in the php. I think it's bypassing my code for redirect.

    Any suggestions? I'm desperate

  2. #2
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: PHP redirect based on form input - but doesn't work. Defaults to generic Thank Yo

    the correct field name is "good_url" not "redirect":
    http://www.tectite.com/fmhowto/redir.php


  3. #3
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: PHP redirect based on form input - but doesn't work. Defaults to generic Thank Yo

    and don't add PHP code...formmail will do this for u.

    sorry, i just read the rest of ur post

    if u want to set good_url based on an answer, that's no problem. its just a field name

    this should work fine:
    HTML Code:
    <select name="good_url"><option value="http://www.mysite.com/folder/page2.html">Page 2</option><option value="http://www.mysite.com/folder/page1.html">Page 1</option>
    </select>

  4. #4
    Join Date
    Oct 2006
    Posts
    11

    Default Re: PHP redirect based on form input - but doesn't work. Defaults to generic Thank Yo

    Quote Originally Posted by crabtree View Post
    and don't add PHP code...formmail will do this for u.

    sorry, i just read the rest of ur post

    if u want to set good_url based on an answer, that's no problem. its just a field name

    this should work fine:
    HTML Code:
    <select name="good_url"><option value="http://www.mysite.com/folder/page2.html">Page 2</option><option value="http://www.mysite.com/folder/page1.html">Page 1</option>
    </select>
    Brilliant! Thank you so much, you are a lifesaver!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Recipient Based on Form Input
    By samalotriviera in forum Features Questions
    Replies: 10
    Last Post: 23-Mar-2010, 08:52 PM
  2. Subject based on form input
    By rabbitkillrun in forum Community Support
    Replies: 2
    Last Post: 26-Jun-2009, 06:54 PM
  3. database lookup based on form input.
    By eLIANT in forum Features Questions
    Replies: 4
    Last Post: 21-Mar-2008, 02:47 AM
  4. database lookup based on form input.
    By eLIANT in forum Community Support
    Replies: 1
    Last Post: 20-Mar-2008, 01:33 PM
  5. Conditions: How to send different HTML forms based on form input
    By bdonnelly in forum Features Questions
    Replies: 3
    Last Post: 22-Oct-2007, 01:07 AM

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