Form Results Display on New Web Page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rkinkade
    New Member
    • Nov 2006
    • 6

    Form Results Display on New Web Page

    Previously I used an .asp Request.Write Request.Form to display the results from a form on a new web page. Is there some similar function in php that I can use? I am no longer using a server that supports the .asp model.

    www.travelagent pros.com/manual2/invoiceform.asp is the form and www.travelagent pros.com/manula2/invoice.asp is the result page

    Access to manual2 is gained by using username=agent, password=succes s
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Originally posted by rkinkade
    Previously I used an .asp Request.Write Request.Form to display the results from a form on a new web page. Is there some similar function in php that I can use? I am no longer using a server that supports the .asp model.

    www.travelagentpros.com/manual2/invoiceform.asp is the form and www.travelagentpros.com/manula2/invoice.asp is the result page

    Access to manual2 is gained by using username=agent, password=succes s
    Of course you can. (you could, while you are doing that, re-arrange the invoiceform.asp so the boxes are nicely aligned). And the link to www.travelagentpros.com/manula2/invoice.asp returns a 404 error.

    Ronald :cool:

    Comment

    • rkinkade
      New Member
      • Nov 2006
      • 6

      #3
      Originally posted by ronverdonk
      Of course you can. (you could, while you are doing that, re-arrange the invoiceform.asp so the boxes are nicely aligned). And the link to www.travelagentpros.com/manula2/invoice.asp returns a 404 error.

      Ronald :cool:
      sorry that was a typo in the url, it's manual2/invoice.asp. And yes it will still return an error because that function.

      So "of course I can" is vague? Think you could enlighten me with some code?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        In your form I cannot, obviously, see what ASP does, but I assume that, since you have a <form action="/manual2/invoice.asp" method="post" name="invoicefo rm" target="_blank" > that you validate the input in the same form en then link to invoice.asp with the user entered values as parameters in either a GET or a PUT structure.

        So what byou want is to replace the invoice.asp with an invoice.php program that has the same functionality (or maybe invoiceform.asp as well??).

        In order to get to some sample code done, show us
        • in invoiceform.asp : how you link to invoice.asp and how you pass the variables
        • in invoice.asp: (part of) the ASP code you are using to gather the input from the GET or POST array and how (only a couple of lines) you make that into the to be displayed invoice screen.

        When we can see that, we can make some sample code to (a) maybe replace the link method to invoice.asp in invoiceform.asp and (b) replace the ASP code in invoice.asp.

        Ronald :cool:

        Comment

        • rkinkade
          New Member
          • Nov 2006
          • 6

          #5
          Originally posted by ronverdonk

          In order to get to some sample code done, show us
          • in invoiceform.asp : how you link to invoice.asp and how you pass the variables
          • in invoice.asp: (part of) the ASP code you are using to gather the input from the GET or POST array and how (only a couple of lines) you make that into the to be displayed invoice screen.

          When we can see that, we can make some sample code to (a) maybe replace the link method to invoice.asp in invoiceform.asp and (b) replace the ASP code in invoice.asp.

          Ronald :cool:
          Thanks. I'll do my best to answer your questions:

          First, on invoiceform.asp the only requirement is that the post=invoice.as p

          Secondly, on invoice.asp the results of the previous form are displayed on the webpage using the following command

          <% response.write request.form("i nvoicenumber") %>

          "invoicenum ber" is replaced as needed with form input names. You simply place it where you want in the html and it displays.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            That doesn't make it any easier to get an insight. I'll try to explain. We may safely assume that the data from invoiceform.asp is transferred to invoide.asp using the POST array.

            Basically, handling a POST array consists of reading all keys/values in the array, assigning each one to a variable and displaying each variable in the invoice screen form using the echo command.

            There are 2 ways for invoice.php to handle this:
            1. echo each variable separately at the appropriate formfield/form position
            2. use a template. invoice.php could be a template that already has all the echoes and form fields defined, so the only thing you have to do is make it a PHP-ready template and read all POST variables in one command into the variables

            I don't know ASP, but seeing the command used to populate the form fields, I think invoice.php is a template.

            So I'll ask you to show the invoice.asp code, not all, just some 50 lines to get an idea of how it is handled now.

            Ronald :cool:

            Comment

            • rkinkade
              New Member
              • Nov 2006
              • 6

              #7
              Originally posted by ronverdonk
              I don't know ASP, but seeing the command used to populate the form fields, I think invoice.php is a template.

              So I'll ask you to show the invoice.asp code, not all, just some 50 lines to get an idea of how it is handled now.

              Ronald :cool:

              Correct, it's a template. Here is some of the code:

              Code:
              <td colspan="2"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Booking 
                            Remarks:</strong><br>
                            <% response.write request.form("bookingremarks") %>
                            </font></p>
                          <p><font size="1" face="Arial, Helvetica, sans-serif">Please note 
                            that all reservations are subject to individual wholesaler or vendor 
                            policies. Please ask your agent for details on your individual booking 
                            regarding cancellations and changes to reservations and fee structures 
                            or check your travel documents. In the case of a dispute all reservations 
                            are subject to these policies.</font> </p></td>
                      </tr>
                      <tr> 
                        <td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
                      </tr>
                      <tr> 
                        <td colspan="2"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Additional 
                            Info:</strong><br>
                            <% response.write request.form("comments") %>
                            </font></p>
                          <p><font size="1" face="Arial, Helvetica, sans-serif">The above referenced 
                            agent is an Independent Contractor for Only Fun Vacations. Should 
                            the above agent be unavailable for customers service issues you 
                            may contact Only Fun Vacations at 800-576-4662 and we will either 
                            contact the agent for you or address your issue.</font> </p></td>

              Comment

              • rkinkade
                New Member
                • Nov 2006
                • 6

                #8
                I am starting to wonder if it would just be easier to create a .pdf form that the user can fill and print?

                Sometimes the simple solution is the last thing we think of...

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #9
                  This is going to be a simple solution, looking at the invoice.php code. We just have to replace the ASP pieces with PHP echo pieces. That is all. Just give me until tomorrow (it is 1.45am now). I'll be back at 10 (my time).

                  Ronald :cool:

                  Comment

                  • ronverdonk
                    Recognized Expert Specialist
                    • Jul 2006
                    • 4259

                    #10
                    At the first line of your to-be PHP script you must declare the code thereafter as PHP code. So the script's first line is[php]<?php[/php]
                    In the statements thereafter you must assign each value in the $_POST array values to a PHP variable (after cleansing it a bit).
                    E.g. the value from $_POST['bookingremarks '] must be assigned to the PHP variable $bookingremarks , and so on.
                    I use a simple foreach statement for that.[php]foreach ($_POST as $key=>$value)
                    $$key = trim(strip_tags ($value));[/php]
                    After all variables have been extracted this way, you are probably at the end of the php code and the html begins, so close this part with statement[php]?>[/php].
                    RECAP: The starting lines of your would-be PHP script now looks like this:
                    [php]<?php
                    foreach ($_POST as $key=>$value)
                    $$key = trim(strip_tags ($value));
                    ?>[/php]
                    Now you must replace the ASP statements that show the value on the screen, by a PHP echo statement.
                    So each statement e.g.
                    [php]<% response.write request.form("v aluename") %>[/php]
                    must be replaced by
                    [php]<?php echo $valuename; ?>[/php]
                    where valuename must be replaced by the actual name in your script.

                    After all ASP statements have been changed to PHP statements, you must rename your script's file type to .PHP, and you are ready to test it.
                    The calling program (invoiceform.ph p) must be adapted so it call the new php script, i.e. change the action="invoice .asp" by action="invoice .php".

                    I cannot see from your sample code if there are any other ASP statements but, if so, come back here.

                    Ronald :cool:

                    Comment

                    Working...