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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question help with php preview and submit form

    Hello everyone! This is regarding HTML forms, PHP .

    My Question:

    How do you create an html formor php form that goes to a preview screen and then allows the user to move back to the form if they made any errors and corrections are needed or click the send button to submit the form. The form's contents are to be send to an email address

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The easiest way is to use a session to save the form data so it is available to both the review page and the form page.

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I'm looking to do a similar thing but I'm not convinced PHP is the way forward, either that or I've not grasped the sessions principle well enough:

    I want the user to enter their personal details, name email address etc THEN they need to fill out instruments that they play, this could be one or could be five instruments. Rather than having an enormous HTML form that in the majority of cases wouldn't be used, I thought it would be neat to have a smaller form asking for the personal details, then a button that would disappear the form they've just filled out and another one asking for instrument details. Another button on that form to fill out their next instrument or submit details to the (SQL) database.

    My n00bness will show with the following thinking:

    One method, have them fill out name etc, click "next" which increments a variable. Start the script with an if($_POST){} statement which if true displays a new form for instrument input, if false defaults to the personal details form. If this makes sense so far, does it make sense to have the instrument variables get incremented by the POST varibale (that's incremented on POST)?

    So page loads, if($_POST)==FALSE, so display personal details. Our post_increment = 0.

    They enter details, so if($_POST)==TRUE, so display instrument details. post_increment now = 1. Make instrument_name variable = instrument_name[post_increment] ?? That way, when they submit again for a new instrument, the second instrument details are stored in instrument_name[2] ??

    That keeps things tidy in one script, rather than passing things back and forth to maybe five pages? All variables held in the usual $_POST global array, instruments numbered according to the post_variable identfier?


    Or do I have the wrong end of the stick?

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Mouseman I think you have the wrong end of the stick but to comply with rules please start your own thread, thanks.
    Rafiki.

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Apologies, I deliberately posted in this thread as it's pretty much the same as what I'm doing right now. I'm just thinking of other ways of doing it. (In other forums I frequent the regulars get very upset and newbies creating threads willy nilly when there's plenty available on the front page to contribute to/discuss in )

    I appreciate it's not identical but using sessions would be one way of accomplishing my goal but I feel messy? Anyways, I'll save that for another place. OP - sessions is the right move for one form to be checked and changed if needed.

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I may as well continue the hijack

    Mouseman if you are amenable to using Javascript/jQuery, you can take advantage of the jQuery UI and use the accordion or the tab widgets which will make it really simple to display one section of the form at a time. One submit will then validate the form on every tab at once. This is the direction I'd look in if I were creating a multi-part form right now.

    http://jqueryui.com/demos/accordion/

    Then again, I just discovered jQuery so my excitement about its power and abilities may be influencing my answers.

    (The OP could also use this technique, actually)

  • #7
    New Coder
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Looks neat, cheers. Might as well throw this into the mix; currently touched upon the obvious in this project: HTML, SQL, PHP, Javascript, CSS. Exciting stuff to try to cram in quickly!

    Lots more reading needed, as ever!
    Last edited by Mouseman; 03-24-2009 at 11:36 PM.


  •  

    Posting Permissions

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