ISSS615 Data Management

ISSS615 Data Management
PHP_LAB1.doc page 1 of 4
SMU Classification: Restricted
PHP Lab 1
Objective:
The objective is to help the students to get hands on writing PHP code. In this lab
exercise, you will create PHP pages based on the requirements specified.
Pre-Requisites:

  1. WAMP Server is installed and the icon is ‘Green’ in colour.
    Submission:
    Please submit all your answers in a single lab1.zip file containing the following to eLearn
    (online) by the end of the class
  2. Exercise1.php,
  3. Exercise2.php,
  4. ex1form.html and ex1result.php
  5. ex3form.html and ex3result.php
    ISSS615 Data Management
    PHP_LAB1.doc page 2 of 4
    SMU Classification: Restricted
    PART 1: Write basic PHP syntax codes
    Exercise 1
    Using php WHILE construct and IF-ELSE statement, write a program to display the count
    of lowercase letter 'a' appearing in the text string "Data Management". Also display total
    number of letters that are not 'a' in the same text string.
    Save the file as Exercise1.php
    Note: You could make use of the functions strlen and substr for this exercise.
    Exercise 2
    Write php program to calculate the cumulative sum of numbers from 1 to 10.
    Display the result in a table format. Save the file as Exercise2.php
    Note: Example of a Table html script that produces a table with 2 rows, a header row and
    a content / data row


    Header 1
    Header 2


    Column 1
    Column 2




    ISSS615 Data Management
    PHP_LAB1.doc page 3 of 4
    SMU Classification: Restricted
    PART 2: Write PHP code for processing HTML Form data

    1. Open a text editor, write the following code, and save the file as ex1form.html

      A simple form


      Enter your name:




    2. Open a new page on the text editor, write the following code and save the file as
      ex1result.php


      print "Hi $_POST[fullname]. Welcome to PHP lab1 !
      ";>

    3. In Internet Explorer/, enter http://localhost/PHPLab1/ex1form.html in the address bar.
      You should see an output as follows
    4. When you enter your name and click on the send button, the following output is
      observed.
      ISSS615 Data Management
      PHP_LAB1.doc page 4 of 4
      SMU Classification: Restricted
      Exercise 3
      Add Gender Identification to the PHP code for processing HTML Form data
      Your task is to modify the ex1form.html to include a dropdown box to allow user to select
      a gender. Depending on the selected gender, you should print either “Miss” or “Mr”
      Hint:
    5. Modify ex1form.html to include another input element, a dropdown box named
      gender (Male & Female).

      Save the modified file as Exercise3Form.html.
    6. Modify the PHP page (ex1result.php) so that it handles the gender information sent
      over by the client and save the modified file as Exercise3Result.php.
      If Female is selected, the following output is observed.
      If Male is selected in the select dropdown list, the following output is observed.
      End of PHP Lab 1
      WX:codehelp

你可能感兴趣的:(mysql)