SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am having my visitors submit their information via a php form...How would I create a confirmatin page with their informatino. I want to redirect them to a new page that contains their information?

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST


  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On the first page make a hidden form with a value of "1" named "confirm." Then in your PHP code check if $confirm==1. If it does then show the confirmation page. If it doesn't then show the normal HTML form.

    If you want me to go into more detail that's no prob.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    d3v:

    Thank you for taking the time to show me that, could you give me more details..I am a novice...what exactly do I need to do? Also, do I need to create a confirmation page in PHP and then send them to that?

    Thanks,
    Dylan

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a really crude example of how to create a form and process for erros and display either an error message or a confirmation message!

    <?

    //Check to see if the form was submitted
    if ($submit) {

    //Sets the intial error flag to 0
    $error = 0;

    //If name was submitted empty set $error = 1 and add error msg to errors array
    if (!$name) {
    $error = 1;
    $errors[] = "Missing Name";
    }
    //If email was submitted empty set $error = 1 and add error msg to errors array
    if (!$email) {
    $error = 1;
    $errors[] = "Missing Email";
    }

    //If data had no errors
    if ($error == 0) {
    //Do your processing stuff here, I assume email results or add to db
    }


    }
    ?>
    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <?

    //Check to see if either the form wasn't submitted or there was an error and display the form
    if (!$submit || ($error == 1)) {

    print '<h2>Sample Form</h2>';
    //If $error = 1 loop through the errors array and print each error
    if ($error == 1) {
    print "<ul>";
    while (list ($key, $val) = each ($errors)) {
    printf('<li>%s', $val);
    }
    print "</ul>";
    }
    printf('<form action="%s" method="post">', $PHP_SELF);
    printf('Name: <input type="text" name="name" value="%s"><br>', $name);
    printf('Email: <input type="text" name="email" value="%s"><br>', $email);
    printf('<input type="submit" name="submit" value="submit">');
    print '</form>';
    }

    //If no errors print the confirmation page
    else {
    printf('Thank you %s, your information was submitted successfully', $name);
    }


    ?>



    </body>
    </html>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •