首页 > > 详细

ISSS615讲解、辅导PHP_LAB1留学生、讲解c/c++,Python设计、辅导Java程序 辅导R语言程序|调试C/C++编程

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
- Exercise1.php,
- Exercise2.php,
- ex1form.html and ex1result.php
- ex3form.html and ex3result.phpISSS615 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:
1. Modify ex1form.html to include another input element, a dropdown box named
gender (Male & Female).

Save the modified file as Exercise3Form.html.
2. 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 ~~

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!