Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile One confirmation email, two different forms

    Hi everyone,
    I am totally new in web programming. Maybe my question sounds so silly for some of you, but i just wanna ask how to program forms in php which will accept multiple steps? For example form 1 post to form 2 then the consolidated results from both forms are posted via one email to the user? Basically i have a registration form, and then a billing form. So, i will need to send an email to the user about all the information that they have input in both forms. Currently i am using two forms which will send two different emails to the user. So, can anyone tell me how can i send only one email but the inputs are from two different forms? Thank you in advance

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So many options. I briefly described them here:
    http://www.codingforums.com/showthre...5&pagenumber=1

    The easiest sollution is just to include them as hidden formfields inside your second form. If this second form then is posted, you can access all formdata in the same way.

    Example:
    suppose form 1 contains a textfield named firstname. Like
    echo('<input type="text" name="firstname" />');
    then inside form 2 you get
    echo('<input type="hidden" name="firstname" value="' . $_POST['firstname'] . '" />');

    Inside the page where you post form 2 to, you can access this formfield just like the other formfields of form 2 ----> $_POST['firstname']


    If you want this a bit more efficient, then you can automatically generate the hidden formfields by looping thruogh the form-collection when you build the page with form 2 in it. Like
    PHP Code:
    foreach_($_POST_as_$varName_=>_$value){
          if (
    $varName != 'submit')){  
    /* supposing your submitbutton of form 1 is called like that.
    you could also add other fields you don't want to drag along */
          
    $hidden .= ('<input type="hidden" name="'$varName .'" value="' $value '" />');
       }
    }
    echo 
    $hidden 
    which will create a hidden formfield inside form 2 + will store the entered data in it, for each formfield of form 1 (except the submitbutton or other fields you exclude.

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was thinking of using session. But since i am very new in php, i dont know how to start. Can you advice me on this? Thank you in advance

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you check the link i posted (my frst post inthere)?

    Why uses sessions? It's only data the user submitted himself and you only need to drag it along for one page, so hiddenformfields are probably the easiest.

    You could use sessions like

    $_SESSION['firstname']= $_POST['firstname'] ;

    and then access it like

    $firstname = $_SESSION['firstname'] ;

    ==> on each page where you use sessionvariables, put session_start() at the top of your php-page !!

    When you use sessionvariable, you could also use a loop, but then you need to use variable variablenames. Like
    PHP Code:
    session_start();
    foreach (
    $_POST as $varName => $value){
          if (
    $varName != 'submit')){  
    /* supposing your submitbutton of form 1 is called like that.
    you could also add other fields you don't want to drag along */
          
    $_SESSION[{$varName }] =  $value ;
       }

    This creates a new sessionvariable for each formfield (except the submitbutton) and stores the posted formfields value in it. The sessionvariables are then named the same as the formfields.


  •  

    Posting Permissions

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