Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) (10 points) Create a PHP page to read one name. Add input validation such tha

ID: 3774911 • Letter: A

Question

a) (10 points) Create a PHP page to read one name. 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.

<?
$nameErrMsg="";
$names="";
if($_SERVER ["REQUESTED METHOD"]=="POST")
{
if (empty ($_POST["NAME"]))
{
$nameErrMsg="Requiring a Name";
}
else
{
$names=test_input ($_POST ["NAME"]);

if(!preg_match("/^[a-zA-z ]*$/",$names))
{
$namesErrMsg="allowing letters and whitespaces only";
}
}
?>

b) (15 points) Upon submission: Print out the complete row for a person in the customer table from assignment 2, that has as lastName the name that was entered.

Use the information from the in-class demos on integrating PHP into MySQL to help build your database integration

c) (5 points) In a text document explain how a) relates to SQL injection

d) (Bonus 5 points): On the screen displaying the customer information include a form that allows the user to change that customer's ZIP code. It should only accept a 5 digit zip code. It should also only change the ZIP code of the specific customer loaded. Again, you don't need to change the input, just allow the user to enter it again. After submitting the form, load a new page showing the updated customer information.

In your submission, include a text document that includes:

Your answer to Part (C)

A link to the PHP page described in part (A) (which should allow us to access parts B and D)

The name of a customer that exists in your database so I (or the grader) can test your work.

Explanation / Answer

<!DOCTYPE html>
<html>
<body>

<?php
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>

</body>
</html>