SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Ste-Adele
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation 3 page form / when hitting back loose all data

    Hi,

    Here is my problem;

    I have a three part form thus I use the $PHP_SELF?action=whatever to go from one to the other.

    Now let say for exemple that I don't fill in the required info on the frst page, I will get a message to that effect and then if I hit the back button on the browser I can start over again. But that way is pretty primitive. So I decided to put in a link on the warning page that would bring me back to the previous form page.

    The link works great on the first page. But when I come on the second or thirs page and omit to enter any or partial information on the form, I get my warning and when I click on my link that represent the action taken on the page 2 or 3, it will not bring me back to my form page but rather to the warning page of the 2 or 1 page depending on wich warning page I am on (2 or 3).

    I thought of putting in the hidden fields of the page that I had just omitted putting in the information but that doesn't work.

    Can somebody help me?

    here is a sample of my code ===>
    PHP Code:
    <?
    if ($action == "lost"){
    ?>
    <form method="POST" action="<? echo ("$PHP_SELF?action=step2pr"); ?>">
    <input name="choicepr" type="radio" value="Logiciel"> 
    <input name="choicepr" type="radio" value="web access">
    <input type="image" name="submit" src="images/spacer.gif" border="0" width="67" height="60" value="Submit"> 
    </form>

    <? 
    }
    ELSEIF (
    $action == "step2pr"){
    $choicepr $_REQUEST['choicepr'] ;

    if (empty(
    $choixpr)) {

    echo(
    "<a href=\"$PHP_SELF?action=lost\">Required field missing. Click here to go back</a>"); 

    }
    else {
    ?>
    <form method="POST" action="<? echo ("$PHP_SELF?action=step3pr"); ?>">
    <input name="name" type="text"> 
    <input name="lastname" type="text">
    <input type="image" name="submit" src="images/spacer.gif" border="0" width="67" height="60" value="Submit">
    <? 
    }
    ELSEIF (
    $action == "step3pr"){
    $name $_REQUEST['name'] ;
    $lastname $_REQUEST['lastname'] ;

    if (empty(
    $name) || empty($lastname) {

    echo(
    "<a href=\"$PHP_SELF?action=step2pr\">Required field missing. Click here to go back</a>"); 

    }
    else {
    ...... and so until I get the data sent by email. My form works well. It's just that I want to fugure a way for the user that fills in the forms, if he or she forgets to enter some information, he or she can click on a link to come back without loosing all of it's data.


    thanks

    MAP

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    map,

    The problem is that you're losing the $_POST array with your programmed back clicks. If you've got all the data captured and popped into hidden form fields, you can go back by submitting that form with the old data (and having it written into the form from the $_POST array if isset()).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Or you could use sessions to store the post data until you reach the end of the form.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Ste-Adele
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks guys, I will try this


Bookmarks

Posting Permissions

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