The document outlines an experiment on developing a web page with data validation in a Mobile Application Development course. It explains the importance of validating user input in PHP, detailing server-side and client-side validation methods, as well as sanitization techniques to prevent security issues. Additionally, it provides a PHP script example for checking the validity of email addresses.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
9 views
php practical 12
The document outlines an experiment on developing a web page with data validation in a Mobile Application Development course. It explains the importance of validating user input in PHP, detailing server-side and client-side validation methods, as well as sanitization techniques to prevent security issues. Additionally, it provides a PHP script example for checking the validity of email addresses.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
DEPARTMENT OF COMPUTER ENGINEERING
Subject: Mobile Application Development Subject Code: 22619
Semester: 6 Course: CO6I-A Laboratory No: Name of Subject Teacher: Name of Student: AFIF IRFAN NAZIR Roll Id: 21203A1005 Experiment No: 12 Title of Experiment Develop web page with data validation
Practical Related Question
1. How to validate user input in PHP? Explain Validating user input in PHP is an important step in web development to ensure the security and accuracy of data. There are several ways to validate user input in PHP, including:Server-side validation: Server-side validation is the process of validating user input on the server-side, which involves checking whether the data submitted by the user meets the required criteria or not. For example, we can check whether the input is empty or not, whether it contains any special characters or not, or whether it is in the correct format or not. PHP provides various built-in functions for server-side validation, such as isset(), empty(), filter_var(), preg_match(), etc.Client-side validation: Client-side validation is the process of validating user input on the client-side, which involves checking whether the data entered by the user is valid or not using JavaScript before submitting the form to the server. Client-side validation can be used to provide immediate feedback to the user without reloading the page. However, client-side validation should not be relied upon solely, as it can be easily bypassed by disabling JavaScript in the browser.Sanitization: Sanitization is the process of cleaning up user input to remove any malicious or unwanted content. For example, we can remove any HTML tags, special characters, or scripts from the user input. PHP provides various built-in functions for sanitization, such as htmlspecialchars(), strip_tags(), htmlentities(), etc. 2. Why is the need to validate user input? Validating user input is essential for any web application because it helps to ensure that the data entered by the user is correct and free from errors. Failure to validate user input can result in various security issues, such as SQL injection attacks, cross-site scripting (XSS) attacks, and other vulnerabilities.If a user inputs malicious data, it could lead to the system executing unwanted and harmful code, causing damage to the system and data loss. Additionally, validating user input ensures that the data entered by the user is consistent with the expected format and type, which can help prevent errors in processing and storing data.Therefore, it is necessary to validate user input before it is processed and stored in the database. This can be achieved through server-side validation techniques such as regular expressions, input sanitization, and error handling. Proper validation of user input helps to ensure the integrity and security of web applications. Exercise Related Question 1. Write a PHP script to check that emails are valid or not. <?php $email = "[email protected]"; // Replace with the email you want to check