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

Thread: Preview

  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preview

    I'm making a form where users insert data into a database. I have a submit button. I want to have a preview button so they can preview their post without entering it into the database. How might I do that?

    Thanks.....
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well it's not that difficult. Just take the contents of the form and echo it to the browser. Using sessions would make it easy. Store the contents of the form in the session. On the preview page echo the contents you stored in the session to the page.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, thanks for the reply. Could you show me some example code?

    Thanks a lot.

    - Stevie
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    What I've done in the past is set a name attribute on the "submit" form element.

    Code:
    <input type="submit" value="<?php print $btnTxt;?>" name="submit" />
    Then my php follows like this...

    Code:
    //set default variables
    $btnTxt="Verify";
    if($_POST['submit'] && $_POST['submit']=="Verify") {
       $btnTxt="Submit";
       //display form with contents from previous page
    }
    elseif($_POST['submit'] && $_POST['submit']=="Submit") {
       //process data and display confirmation page
    }
    else {
       //no post data, display empty form.
    Then all my form elements are something like this..
    Code:
    <input type="text" name="firstName" id="firstName" value="<?php print $fName;?>"/>
    Which means for each of the conditions above, I need to set the variables

    ie
    Code:
    $fName = $_POST['firstName'];
    And so on.


  •  

    Posting Permissions

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