Question: Please write a PHP Code to display and store the following results as showing in the pictures below using. This is my codes below Project
Please write a PHP Code to display and store the following results as showing in the pictures below using.
This is my codes below
Project 1
function validate_input($input)
{
$input=trim($input);
$input=htmlspecialchars($input);
return $input;
}
if($_POST["submit"])
{
$name = validate_input($_POST["name"]);
$email = validate_input($_POST["email"]);
$major = validate_input($_POST["major"]);
if(empty($name))
$nameMSG ="Missing";
if(empty($email))
$emailMSG = "Missing";
else
{
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
$emailMSG = "Invalid email format";
}
}
?>
Welcome to my online Web Based Test!!!
Please answer the following questions:
Name: *
E-mail: *
Choose your major area of study:
Questons 1 (25points)
If my name is Ciapha P Dorley Jr, what is my last name?
A. John
B. Meshack
C. Ciapha
D. Dorley
Questons 2 (25points)
If I love to eat Rice everyday, what is my favoriate food to eat?
A. Fufu
B. udon
C.Rice
D. Pizza
Questons 3 (25points)
I was born in Liberia, so what is my hometown's name?
A. Atlanta
B. Liberia
C. Nigeria
D. Japan
Questons 4 (25points)
If I love the number 7, so what is my favoriate number?
A. 7
B. 87
C. 17
D. 77
Show correct answers after submission.
echo "Your test results are: ".$results." ";
if($_POST["submit"])
{
echo "Name:".$_POST["name"].". ";
echo "E-mail:".$_POST["email"]." ";
echo "Major:".$_POST["major"]." ";
}
?>
if($_POST["submit"])
{
$score = 0;
$nq = 2;
$pointsPQ = 100/$nq;
if($_POST["Q1"] == "D")
$score+=25;
if($_POST["Q2"] == "C")
$score +=25;;
if($_POST["Q3"] == "B")
$score +=25;
if ($_POST["Q4"] == "A")
$score +=25;
}
echo "Your grade for this test is: ".$score." ";
?>
Welcome to this Web Based Test!!! Please answer the following questions: Name derley E-mail: cderley .edu Choose your major are of y Security Questos 1 (Spoints) If my name is Will Smith, what is my first name? A Will This is the correct answer! OB Smith OC Will Smith OD Smith Will Questons 3 (25 points) If I was born and grew up in New York, what is my hometown's name? . OB Las Vegas OC Detroit OD New York This is the corect answer! Questons 4 (25points) If my birthday is 10/27/1998, what is 10-27? This is the correct answert OA 27 R 37 OC. 17 OD 47 Show correct answers after submission Submit this test Reset Your test results: Name sdorley Email: cdorley aggc.edu Major: Security Your grade for this test is: SO
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
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!