php form issue ..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eeau1973
    New Member
    • Jul 2006
    • 4

    php form issue ..

    hi ... im looking for an example to make a form where the user input data, and then the user click on a buttom that after that "click" the user is taken to an other form to continue filling data that later is sent to an email address ...

    if there is no example, would you please tellme how to do this process ?..
    thanks in advance ...
    greetings .. emmanuel
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Gotta give some more info, such as:
    • do you want validation for the first form to be performed within the first form?
    • is the name of the second form dependent on input of the first form?
    • do you want to pass information from the first to the second form using GET or via SESSION variables?


    Ronald :cool:

    Comment

    • eeau1973
      New Member
      • Jul 2006
      • 4

      #3
      Hi ... thanks for the reply ..

      Originally posted by ronverdonk
      Gotta give some more info, such as:
      • do you want validation for the first form to be performed within the first form?


      No, i don“t need validation data for the first form ...maybe for the second form in some fields
      • is the name of the second form dependent on input of the first form?

      No, i just need to continue filling fields
      • do you want to pass information from the first to the second form using GET or via SESSION variables?

      i use post in my forms, but if you think using get is ok thanks a lot ...

      Thanks a lot again !
      :D



      Ronald :cool:

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        I really don't understand why you would want to have a 2-part form, but the following shows how you could do this. I used a HTML file for the first one, since there is no PHP involved.

        [PHP]
        FORM1.HTML code:
        <html>
        <head>
        <title>Testit </title>
        </head>
        <body>
        <form name="myform1" action="form2.p hp" method="POST">
        Enter value for form 1 <input type="text" name="field1" />
        <input type="submit" name="submit" value="Submit form1" />
        <input type="hidden" name="_submit1" value="1" />
        </form>
        </body>
        </html>

        FORM2.PHP code:
        <?php
        if (isset($_POST['_submit2'])) { // called from this script
        // validate $_POST['field2'] etc.
        // do whatever you want to with that data
        echo 'submit=2' . $_POST['field2']; // just for your test
        }
        elseif (isset($_POST['_submit1'] )) { // called from form1
        // validate $_POST['field1'] etc.
        echo 'submit=1' . $_POST['field1']; // just for your test
        // display form2
        ?>
        <form name="myform2" action="form2.p hp" method="POST">
        Enter value for form 2 <input type="text" name="field2" />
        <input type="submit" name="submit" value="Submit form2" />
        <input type="hidden" name="_submit2" value="1" />
        </form>
        <?php
        }
        ?>[/PHP]

        The echo's are there just for the test.
        Hope this is what you meant, though I can't think why.

        Ronald :cool:
        Last edited by ronverdonk; Jul 28 '06, 04:41 PM.

        Comment

        • eeau1973
          New Member
          • Jul 2006
          • 4

          #5
          Exactly .. that`s the html code that i need ... now the thing is how can i send an email that contains both data fields forms ... i mean the data that the user input in form1 and in the form 2 ...

          thanks in advance ... :D

          Comment

          • iam_clint
            Recognized Expert Top Contributor
            • Jul 2006
            • 1207

            #6
            you will do something like this eeau

            Code:
             FORM1.HTML code:
            <html>
            <head>
            <title>Testit</title>
            </head>
            <body>
            <form name="myform1" action="form2.php" method="POST">
                Enter value for form 1 <input type="text" name="field1" />
              <input type="submit" name="submit" value="Submit form1" />
            </form>
            </body>
            </html>
            
            FORM2.PHP code:
            <?php
            $field1 = $_POST['field1'];
            if (isset($_POST['submit'])) {
            //display form 2
            ?>
            <form name="myform2" action="form3.php" method="POST">
              Enter value for form 2 <input type="text" name="field2" />
              <input type="hidden" name="field1" value="<?=$field1?>">
              <input type="submit" name="submit" value="Submit form2" />
            </form>
            <?php
            }
            ?> 
              
             
            FORM3.PHP code:
            <?php
            $field1 = $_POST['field1'];
            $field2 = $_POST['field2'];
            if (isset($field1) and isset($field2)) {
            ?>
            Thanks for filling out this form!
            <?
            } else {
            ?>
            All Fields Not Filled Out!
            <?
            }
            ?>

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              form2: start a session.
              in '_submit1' processing:
              save the field1 variable in the session
              display form2

              in '_submit2' processing:
              build your email message with field1 and field2
              send the email

              That's it.

              Ronald :cool:

              Comment

              • iam_clint
                Recognized Expert Top Contributor
                • Jul 2006
                • 1207

                #8
                You could do it that way but transferring hidden fields works also choose your way and good luck.

                Comment

                Working...