CS310 Assignment: 02 Solution

Assignment Details

Due Date:

Friday 20, June, 2025

Extended Date:

Saturday 21, June, 2025


Assignment Question Details:

Assignment No.  2
Semester: Spring 2025

CS310 – Open Source Web Development

 

 

Instructions

Please read the following instructions carefully before submitting the assignment solution:

It should be clear that your assignment will not get any credit/marks if:

o        Assignment is submitted after due date.

o        Submitted assignment does not open or file is corrupt.

o        Assignment is copied (From internet/students).

 

Objectives

 

  1. Understanding Form Validation
  2. Implementing Input Sanitization
  3. Error Handling and Feedback
  4. Practical Application of PHP Forms

 

 

Assignment Submission Instructions

You have to submit only “.php” file of your code on the assignments interface from your LMS account.

Assignment submitted in any other format will not be accepted and will be scaled with zero marks. No excuse will be accepted on submitting solution file in any other format.

For any query related to assignment, please contact cs310@vu.edu.pk.

Problem Statement:

You are required to create a job-application form for hiring. The form collects the following details from applicants:

  • Full Name
  • Email Address
  • Phone Number
  • Desired Position (select from a list)
  • Cover Letter

Your assignment involves the following tasks:

  1. Input Validation:
    • Full Name: Must not be empty; only letters and spaces.
    • Email Address: Must be in a valid email format.
    • Phone Number: Must be exactly 10 digits.
    • Desired Position: Must be one of the provided options (e.g. “Frontend Developer”, “Backend Developer”, “UI/UX Designer”).
    • Cover Letter: Must not exceed 500 characters.
  2. Input Sanitization:
    • Trim leading/trailing whitespace from all fields.
    • Strip out any HTML tags or script characters.
  3. Error Handling:
    • Show real-time error messages next to each field if its value is invalid (e.g. “Phone must be 10 digits”).
    • Prevent form submission until all fields pass validation.
  4. Confirmation Message:
    • When the user submits valid data, display a summary: for example “Thank you, [Sanitized Full Name], for applying to [Sanitized Position].
      We will reach out to you at [Sanitized Email] or [Sanitized Phone] shortly.
      Your cover letter: “[…]”

Sample Input and Validation Criteria:

Input Field

Criteria

Example

Full Name

Only letters & spaces, not empty

John Smith

Email Address

Valid email format

john.smith@example.com

Phone Number

Exactly 10 digits

0312345678

Desired Position

One of: Frontend Developer, Backend Developer, UI/UX Designer

Backend Developer

Cover Letter

Maximum 500 characters

“I’m excited to join your team because…”

 

 

Sample Output:

Weeks Covered:  7 - 9

Due Date: Friday, June 20, 2025.

VuPark Approved

Saturday 14, June, 2025