HTML form preview

Discussion in 'PHP' started by inderpal, Aug 30, 2006.

  1. #1
    Hi All,

    I have a HTML form (lots of input fields). I want to provide form preview to the user before sending all the values to the database. I can do that by redirecting to some another page or on same page and provide a back and submit button. When user clicks on submit button, I need to store all the values to the the databse. Do I need to store all the values in a hidden fields? If there is any other way, please provide me any pointers.

    Thanks in advance!!

    Best Regards,
    Inderpal Singh
     
    inderpal, Aug 30, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you are giving the user a preview form you need to populate the form with the previous values. I use this technique to deal with errors in forms before they are finally submitted. For instance, when the form is first displayed the name input section looks like this:

    <input type="text" name="name" size="25" value="" />

    When the form is previewed, it is redisplayed to the user like this:

    <input type="text" name="name" size="25" value="Inder Pal" />

    In your php code you might have a variable called $userName and it might be sset thusly:

    $userName = "";
    if(!empty( $_POST['name'] )) { $userName = $_POST['name']; }

    In section of the script with displays the form, you might write:
    <input type="text" name="name" size="25" value="<?php echo $userName; ?>" />

    -- or --

    echo '<input type="text" name="name" size="25" value="' . $userName . '" />';
     
    clancey, Aug 30, 2006 IP
  3. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes it's right, but for better prview option ,,,

    You can post this form to another page for preview..and all forms valuse will store in hidden field..

    If users say Confirm then it will insert all form value into database
    otherwise just cancel the registration and let's redirect it to any wanted page..
     
    singh.ajit05, Apr 1, 2008 IP
  4. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes it's right, but for better prview option ,,,

    You can post this form to another page for preview..and all forms valuse will store in hidden field.. Here you show values for user confiramtion.

    If users say Confirm then it will insert all form value into database
    otherwise just cancel the registration and let's redirect it to any wanted page..
     
    singh.ajit05, Apr 1, 2008 IP