Question: a) Create a php page to read the name of a school. Add input validation such that the name is required, and only contains letters

a) Create a php page to read the name of a school. Add input validation such that the name is required, and only contains letters and white space (see php tutorial). You do not have to modify the input. You only have to alert the user of the inappropriate use of special characters, and give him or her another chance to enter the name. (Answered with code below)

CODE:

alert("Name field is required, please try again.");'; } else { $names=test_input ($_POST ["NAME"]);

if(!preg_match("/^[a-zA-z ]*$/",$names)) { echo ''; } } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?>

Name:

b) Explain how a) relates to SQL injection.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!