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

text reference: PHP and MySQL for Dynamic Web Sites 4th edition 1. creat a new f

ID: 3802645 • Letter: T

Question

text reference: PHP and MySQL for Dynamic Web Sites 4th edition

1. creat a new form that takes some input from the user. Then create the php script that validates the form data and reports upon the results.

2. rewrite the gender conditional in handle_form.php (script 2.4) as one conditional instead of two nested ones. hint: you'll need to use the AND operator.

3. rewrite handle_form.php (script 2.4) to use $_post instead of $_request.

4. rewrite handle_form.php (script 2.4) so that it validates the age element. hint: use the $gender validation as a template, this time checking against the corresponding pull down option values (0-29, 30-60, 60+)

5. rewrite the echo statement in the final version of handle_form.php (script 2.5) so that it uses single quotation marks and concatenation instead of double quotation marks

Explanation / Answer

<?php
if (isset ($_POST['gender'])) {
$gender = $_POST['gender'];
if ($gender == 'M') {
$greeting = '<p><b>Good day,
Sir!</b></p>';
} elseif ($gender == 'F') {
$greeting = '<p><b>Good day,
Madam!</b></p>';
}
} else {
$gender = NULL;
echo '<p class="error">Gender
should be either "M" or "F"!</p>';
}