You are on page 1of 2

Web Development

Lab4 : Basic PHP

Objective: The purpose of this lab is to explore PHP and to learn how to use the PHP programming
language to solve problems and to use it to fulfill classic web functions such as forms treatment.

Based on your website from Lab 2 (HTML+ CSS), add the following functions in your form to be
treated when the form is submitted:

1. If one or more elements of the form is empty, a javascript alert must be displayed: “One or
more fields are empty. Please check your coordinates!”.

2. Add an email address in this form. Then, extract the domain_name from the email address
using the predefined function “explode”. Display a php message “You are a member of
this domain: domain_name”.
3. Write a PHP script that checks if the text area “message” contains your “lastname”. If the
introduced text contains the “lastname”, then the program displays the number of
occurrences of this word in the message and gives the index at which the first occurrence
of the lastname appeared.
You can use the PHP functions “substr_count” and “strpos” in this exercise.
4. Data in the form must be treated to display the values entered by the user in a table. Write
necessary PHP+CSS code to make your PHP page looks like the image below:

CS220 Web Development 1


CS220 Web Development 2

You might also like