0% found this document useful (0 votes)
17 views

Lab 04 PHP

This lab aims to explore PHP by adding form validation and processing functions to an existing HTML/CSS website from Lab 2. Specifically, the lab tasks students to: 1) Validate that no fields are empty using JavaScript; 2) Extract the domain from an email using explode() and display it; 3) Use substr_count() and strpos() to check for and count occurrences of the lastname in a textarea; and 4) Display the entered form values in a table using PHP and CSS.

Uploaded by

DaLYathTv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lab 04 PHP

This lab aims to explore PHP by adding form validation and processing functions to an existing HTML/CSS website from Lab 2. Specifically, the lab tasks students to: 1) Validate that no fields are empty using JavaScript; 2) Extract the domain from an email using explode() and display it; 3) Use substr_count() and strpos() to check for and count occurrences of the lastname in a textarea; and 4) Display the entered form values in a table using PHP and CSS.

Uploaded by

DaLYathTv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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