Page 305 - Computer Software Application TP - Volume 1
P. 305

COMPUTER SOFTWARE APPLICATION - CITS





                              <body>
                            <?php
                 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)

                 {
                    $userId = $_POST[‘user_id’];
                    $username = $_POST[‘username’];
                    // Process the values
                    echo “User ID: $userId, Username: $username”;
                 }

                 ?>
                  </body>
                              </html>
           3  Save the program in  C:\Apache24\htdocs in a folder with .php extension

           4  Run the Apache services from windows services
           5  Open the browser and type the following address
              http://localhost/foldername/
           6  Click the .html file to run and verify the output
































           1  Provide a code example to determine the request method (GET, POST, etc.) used by a client in PHP.
           2  Provide examples of accessing common request headers in PHP such as $_SERVER[‘HTTP_USER_AGENT’]
              and $_SERVER[‘HTTP_REFERER’].
           3  Provide a code example demonstrating how to create a simple HTML form with a text input field and retrieve
              the user’s input using the $_GET superglobal.

           4  Provide a code example of a PHP file that contains an HTML form for acquiring user input.
           5  Provide a code example of setting hidden field values in one page and retrieving them in another page using
              the $_POST or $_GET superglobals.




                                                           290

                               CITS : IT & ITES - Computer Software Application - Exercise 56
   300   301   302   303   304   305   306   307   308   309   310