Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Need a hand in this multiple page contact form thing

    Alright, so I've been working on this site for my company and I am completely stuck on trying to create a form that is spread out on 2 pages. The first part of the form which is on the home page has 3 questions which are drop down menus. After the user hits submit, I want it to take them to a general contact form. Once they submit that I want all the data to be mailed out to a specific email address. I've been looking everywhere and it's just been driving me crazy trying to figure this out.

  • #2
    New Coder
    Join Date
    Jan 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Couple ideas for you. So I'm assuming this is a simple PHP POST method form (or GET doesnt really matter) and you want to know how to pass the data from page to page. You can take one of few approaches:

    1. Have the first form pass data to the second form and populate HIDDEN fields. So for example:

    PHP Code:
    <form>
    <
    input type="hidden" name="from_first_form" value="from_first_form_val" />
    </
    form
    The other method, which i'd personally do:

    2. Store the form submission data to a database or file and read it back in at the end of the process all at once. You'd only need to pass SESSION information to make sure it's the same person going through the form.

    And now that I mention it:

    3. You can use SESSION value to store data as they navigate the site. Set the $_SESSION values to the submitted values and then at the end of the form process mail all those values.


    Thanks,
    Anthony
    Nerd Stuff (code, rrdtool, monitoring, etc):

    blog.anthonyhurst.com

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    ok but if I take option one, wouldn't I have to do a start session either way?

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by eiger23 View Post
    ok but if I take option one, wouldn't I have to do a start session either way?
    No. You could populate the hidden fields using POST. Could be easier, considering you're submitting the first form to get to the second one.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

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