#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Lancaster, PA, USA
    Posts
    8
    Rep Power
    0
    Could someone give me a little snippet of sample code to get me rolling? I have a form and I would like to have a confirmation page show up first before sending the form off to the mysql d-base. Like this.
    --------------
    You have submitted the following info:
    blah
    blah
    blah
    Is this correct Yes/No
    --------------
    Yes - send on the form info to the d-base
    No - returns you to the form
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Bochum, NRW, Germany
    Posts
    13
    Rep Power
    0
    Hi gszczyrb!

    I'm already a newbie to php, but i would try something like this:

    This is the code of my "confirm.phtml" file

    <?php

    switch ($action)
    {
    case 'ask':
    echo "Values correct?";
    echo "<br>Name: ".$name;
    echo "<br>Age: ".$age;
    echo "<br><a href=confirm.phtml?action=yes>Yes</a>n";
    echo "<br><a href=formular.html>No</a>n";
    break;

    case 'yes':
    $sql_query = "INSERT [....]";
    // execute SQL-query here
    break;
    }

    ?>

    You have to call the skript from your form-file with the parameter "ask" (like: <form action=confirm.phtml?action=ask method=post>

    Ok, there is one bug, if you select no, you go back to your form (he!), but the form is empty :-(

    so far...
    Martin
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Lancaster, PA, USA
    Posts
    8
    Rep Power
    0
    I forgot to mention. I'm using a GET method, not a POST method. This probaly makes a difference I guess.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    This is how i would do it.

    Form.php3 firstly looks like this...
    <html><body>
    <?
    {
    echo "
    <form method="post" action="confirm.php3">
    <input type="text" name="name" value="$name">
    <input type="text" name="age" value="$age">
    <input type="text" name="height" value="$height">
    <input type="submit" name="Submit" value="Submit"></form>";
    }
    ?>
    </body></html>


    Form.php3 then goes to confirm.php3 which looks like this.

    <html><body>
    You have submitted the following info:
    <?
    {
    echo "age: $age<br> name: $name<br> height: $height<br>

    Is this information correct?
    <a href="submit.php3?age=$age&name=$name&height=$height">Yes, go on</a><br>
    <a href="form.php3?age=$age&name=$name&height=$height">No, go back</a>
    ";
    }
    ?>

    If yes is selected, it goes to submit.php3 where the variables are added to mysql.

    If no is selected, it goes back to form.php3 where the information the user previously entered will be found as the default in the textboxes.

    submit.php3 is simply a page which has the code to add the variables to MySQL and says..."Thankyou, your information has been entered"

    I have not tested this but it should work ok.

    Let me know
    Basil
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Lancaster, PA, USA
    Posts
    8
    Rep Power
    0
    Thanks to both of you. Martin I wasn't able to get yours to work, but that is probably just my amateurness showing. I do understand more about 'switch' now though. Thanks.

    Tantrum, I used your script and it works great. Exactly what I was looking for. Thanks.

    One more question. In the final part, when it passes the variables to submitform.php, is there a limit on the number of varaibales I can pass? It worked fine in my test dbase with only six variables, but my real dbase has over 40 variables.

    Thanks again
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by gszczyrb:
    One more question. In the final part, when it passes the variables to submitform.php, is there a limit on the number of varaibales I can pass? It worked fine in my test dbase with only six variables, but my real dbase has over 40 variables.

    Thanks again
    [/quote]

    I dont think so gszczyrb. There probably is a limit...but i think 40 or 50 should work fine

    Basil
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Bochum, NRW, Germany
    Posts
    13
    Rep Power
    0
    The maximum length you can pass thru an URL is about 2.000 characters (i've read this in the german book "php - Grundlagen und Loesungen") And everything counts even variable names, values and seperators.

    Martin

Similar Threads

  1. auto populating form
    By usrbin in forum PHP Development
    Replies: 1
    Last Post: February 11th, 2004, 01:10 PM
  2. auto populating form
    By usrbin in forum PHP Development
    Replies: 4
    Last Post: February 11th, 2004, 11:52 AM
  3. Avoid form resubmission when REFRESH clicked
    By rahulgup in forum ASP Programming
    Replies: 0
    Last Post: February 5th, 2004, 01:21 PM
  4. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 06:40 PM
  5. form creation using php
    By emzyme in forum PHP Development
    Replies: 4
    Last Post: January 15th, 2004, 06:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo