Results 1 to 10 of 10

Thread: Simple form question

  1. #1
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Simple form question

    Hey all, so I built a simple email form and I want the form to go to a "Submission Successful" is there anyway to do this without redirecting to another page? I just want to form to be gone after they submit so they don't submit twice.

    Thanks,
    John

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    show us your code. You can use a conditional statement to present the form -or- a success message, depending on if the form has been submitted or not.

  3. #3
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    ok this is what I have so far, it'll show the message but the form stays put, but I want ti to go away.

    PHP Code:
    function success($wufoo_response){
        
    $success $response->submit[0]->success;
        if (
    $success == "true") echo "Thanks for filling out my survey! I will take into consideration your input and modify this site to suit you! Enjoy!";
        else return 
    false;


  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    what action does your form have? do you submit to a different page, or is the form submission processed on the same page as the form appears?

    Something like this is what I'm thinking:
    PHP Code:
    <?php
    if (!isset($_POST['formsubmission'])) { //if form is not yet submitted, the form will display
       
    echo "<form action=\"".$_SERVER['PHP_SELF']."\">
          "
    //form goes here
          
    "<input type=\"submit\" name=\"formsubmission\" value=\"Submit\">";
       }
    else { 
    //if the form was submitted, then the submission will be processed and success message displayed - form is not displayed
       //code to process form
       //then, echo your success message here
       
    }
    ?>
    Last edited by traq; 05-24-2009 at 07:20 PM.

  5. #5
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    the successful message shows on the form page (same page)

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by jzhang1013 View Post
    the successful message shows on the form page (same page)
    yes, but where is the form submission processed? what is the action attribute of the form?
    PHP Code:
    echo "<form action=\"???\">" //is the form processed on the same page? 
    If the same page shows and processes the form, you can use the if...else statement to show the form if it hasn't been submitted, or the success message if it has.

  7. #7
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    <form id="form2" name="form2" class="wufoo topLabel" autocomplete="off"
        
    enctype="multipart/form-data" method="post" action="#public"
    yes it is.

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    okay, so:
    PHP Code:
    <?php
    if(!isset($_POST['form2'])){
       echo 
    ""//put form here
    } else {
       
    // process your form here and set $success to true if successful
       
    if ($success == true) {
          echo 
    "Thanks for filling out my form";
       } else {
          echo 
    "There was a problem! Please try again";
    }
    ?>

  9. #9
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    so by using the above code the form will disappear and the success message will appear in its places correct?

  10. #10
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    it should. put your existing code in the correct places and try it out. Basically, the "if" tells your server that, if the form hasn't been posted, to display the form; and if it has, to process it.
    Let me know how it goes.

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
  •