Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Thanked 0 Times in 0 Posts

    Cool Combining multiple forms to send in one E-mail

    I'm really stumped on this problem.
    Using php I have created a form in Dreamweaver that is a timed test. It goes like this:
    Page 1: Name/ID
    Page 2/3/4: Test questions
    Page 5: Survey
    Each time they submit the results to go to the next page, it sends me an e-mail of the results. Problem is that it sends a separate e-mail for each page, so I get 5 separate e-mails for each person that takes the test. Can someone point me in the right direction on what I can do to combine all of the results into 1 e-mail? I have looked into session variables and arrays but I'm not sure what to do.

    This is what I envision to do but let me know if there's a better way to do it.

    So option 1)
    Form 1 submit ---> Store results in Form 2 - Form 2 Submit ---> Store results from F1 & F2 - Form 3 Submit ---> Sends email of results from F1, F2, and F3


    Form 1 Submit ---> Store results in Form 3
    Form 2 Submit ---> Store results in Form 3
    Form 3 Submit ---> Email results of Form 1, 2, and 3

  2. #2
    Codeasaurus Rex
    Join Date
    Jun 2008
    Redmond, WA
    Thanked 100 Times in 94 Posts
    You've got the solution to the problem: you need to store the form data.

    Now, judging by the fact you're asking the question, you're probably not sure which way to store it.

    You've got three main (read: sensible) ways: Cookies, Sessions, and Database.

    Database is the secure and highly scalable option, but you'll need to invoke sessions to do it. Doesn't sound like the optimal choice for your situation.

    Cookies are fun, but they are dependent on cookies being enabled by the host machine (as are sessions, frankly, to an extent).

    Sessions are probably going to be your best bet.

    Here's a good looking tutorial that should tell you just how to store this information from one page to another:


    Your adaptation in a nutshell (but read the tutorial before you try to analyze this):

    PHP Code:

    // On page 1
    $_SESSION['mySurvey'] = array( "data" => array() );  // Create an array to put our data in. We'll use the format $_SESSION['mySurvey']['data']['survey_one']

    // Pages 1 through final

    // Now let's say you've only got one question on this page and the answer is stored in $answer.
    // Let's make our result array

    $results = array( "Question could go here as the key" => $answer );

    // Now store your results in the session
    $_SESSION['mySurvey']['data']['survey_one'] = $results
    Then, on the final page, you can iterate over your results (possibly using a foreach loop, and then format it however you'd like.
    Last edited by ShaneC; 04-10-2012 at 05:37 AM.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  3. Users who have thanked ShaneC for this post:

    BHayes (04-11-2012)

  4. #3
    New to the CF scene
    Join Date
    Apr 2012
    Thanked 0 Times in 0 Posts
    I won't be working on it again until tomorrow so I'll try it out then.

    Thank you so much for getting me on track.


Tags for this Thread

Posting Permissions

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