CSci 115: Computing and the Internet
Home Syllabus Assignments Tests

Exam 1 Review

[1] [2] [3] [4] [5] [6] [7]

Problem X1r.1.

Suppose we have the following HTML form.
<form method="post" action="grade.php">
<input type="text" name="data" />
<input type="submit" value="Submit" />
</form>
Complete the below file grade.php so that it outputs You received an A when the value typed in the text field is at least 90; You received a B when the text field is at least 80; and You did somewhat poorly otherwise. otherwise.
<?php import_request_variables("pg", "form_"); ?>
<html>
<head><title>Grade Result</title></head>
<body>
<?php
    if($form_data >= 90) {
        echo "<p>You received an A.</p>";
    } elseif($form_data >= 80) {
        echo "<p>You received a B.</p>";
    } else {
        echo "<p>You did somewhat poorly.</p>";
    }
?>

</body>
</html>