hi,

i have 3 forms for creating invitation cards.

form 1 asks users for data input eg names, address, date of event etc

form 2 is to display the data obtained from form 1 in three different styles for users to choose which style they want through the use of radio buttons. each style has different phrases, layout etc.

the script for processing form 2 has many if and else statements as well as echo.

form 3 asks for card quantity details etc.

the task:

i want to save the php output of the "chosen style" at stage 2 and embed it in the email (to the webmaster) as part of the order details together with data obtained from form 3.

how to do this please? output buffering or something else? i would like to avoid writing to files or database if possible.

    just $_POST the information throughout each page. you can save the values of the first page using "hidden" form elements..

    page1

    <form action="page2.php" method="post">
    <input type="text" name="text1">
    <input type="submit">
    </form>
    

    page2

    <form action="page3.php" method="post">
    <input type="hidden" name="text1" value="<?php echo $_POST['text1']; ?>">
    <input type="text" name="text2">
    <input type="submit">
    </form>
    

    and then put all the data processing code and your mail() function on the third page..

    page3

    <form action="page3.php" method="post">
    <input type="hidden" name="text1" value="<?php echo $_POST['text1']; ?>">
    <input type="hidden" name="text2" value="<?php echo $_POST['text2']; ?>">
    <input type="text" name="text3">
    <input type="submit" name="formsubmit">
    
    if($_POST['formsubmit']) {
    
    $var1 = $_POST['text1'];
    $var2 = $_POST['text2'];
    $var3 = $_POST['text3'];
    
    // your mail function etc...
    
    }
    

      thanks a lot for the detailed explanation, notaloser.

      i think i should have said how to store the a certain part of the static html output after the raw data has been processed by php statements. any ideas?

        i dont quite understand.. do you have an example?

        **edit.. i think what you are trying to do involves the same process.. you can process the information from the first page and still $_POST the form data onto the next page using the "hidden" input type

          radio-button 1: card design choice 1
          radio-button 2: card design choice 2
          radio-button 3: card design choice 3

          each available design has similar php script to process as follows:

          <?php 
          
          if ($_SESSION['wedding_hosts'] == "bride_and_groom") {
            echo "thier marriage";
            echo "\n\n";
          }
          elseif ($_SESSION['wedding_hosts'] == "brides_parents") {
            echo "the marriage of their daughter";
            echo "<br />".$_SESSION['bride'];
            echo "<br />with";
            echo "<br />".$_SESSION['groom'];
            echo "\n\n";
          }
          
          // more if and else and echo ...
          ?>

          i don't want to save the above php variables. i want to save the html output after the above mentioned php scripts have processed the form data according to the if and else statements and the user has selected which of the 3 card designs they want. only one card design using radio button can be selected and this is the chunk of html output that i want to save while the html code of the other two unselected designs will be discarded.

            the way you will pass the information from page2 to page3 is by saving it into a variable and passing it similarly to what i explained above.

            there isnt really a way to save what is echoed out for the next page other than what im suggesting.. do you see?

            also, i havent seen the rest of your code but using sessions to pass information from page1 to page2 doesnt seem very effecient.

              hey hey,

              they are session vars because they will be needed in other pages.

              one possible way to do what i want to do is through:

              ob_start: To begin capturing the output
              ob_get_contents: To get the contents in a variable
              ob_end_flush: To send the data to the browser

              the thing is i want to show all the html output first for users to choose which design they want and then only keep the html output of the chosen design. i'm not sure whether ob_end_flush will accomplish what i want to do though...

                ob_start() will start capturing all your outputted information like you want, but i dont know too much about output buffering and i dont believe you can eliminate outputted information that you do not want to store..

                sorry that i cant help you with output buffering, not really my thing

                  errr.. it seems to be working with output buffering.

                  for each of the 3 php scripts on the php page:

                  
                  Card Design Choice 1:
                  
                  <?    
                  
                  ob_start();
                  
                  // if ... else, echo statments to process form data and output html code
                  
                  $_SESSION['content1'] = ob_get_contents();
                  
                  ob_end_flush();
                  
                  ?>
                  
                  Card Design Choice 2:
                  
                  <?    
                  
                  ob_start();
                  
                  // if ... else, echo statments to process form data and output html code
                  
                  $_SESSION['content2'] = ob_get_contents();
                  
                  ob_end_flush();
                  
                  ?>
                  
                  Card Design Choice 3:
                  
                  <?    
                  
                  ob_start();
                  
                  // if ... else, echo statments to process form data and output html code
                  
                  $_SESSION['content3'] = ob_get_contents();
                  
                  ob_end_flush();
                  
                  ?>
                  

                  then i just have to write some if and else statements to pick the right chunk of html code for the chosen card design (ie $SESSION['content 1'], $SESSION['content 2'], or $_SESSION['content 3']) later and send it off in an html email to the webmaster.

                  more testing now..

                  thanks a lot of your help , notaloser. i've learned something new about passing hidden vars from your code. 😃

                    Write a Reply...