Question: I have a problem with session_start(), I could'nt find the problem. (see the attached) new.php : Please fill in the blanks below to take the

I have a problem with session_start(), I could'nt find the problem. (see the attached)

I have a problem with session_start(), I could'nt find the problem. (see

new.php :

Please fill in the blanks below to take the test

Name:

Email:

Id Number:

********************

Mathtest.php :

//session_start() is required to start the session

session_start();

//declaring variables $name and #email

$name="";

$email="";

//for first time request

//checking if button on new.php is clicked

if(isset($_POST['btnSubmit']))

{

//if yes

//put the value of variable name in the session

$_SESSION['name']=$_POST['name'];

//assign the value to $name variable

$name=$_POST['name'];

//put the value of variable email in the session

$_SESSION['email']=$_POST['email'];

//assign the value to $name variable

$email=$_POST['email'];

}

//for second request

else

{

//take value from session variables

/ame

$name=$_SESSION['name'];

//email

$email=$_SESSION['email'];

}

?>

Welcome

Your email address is:

Here is your question:

//generating two random numbers

$no1=rand(1,100);

$no2=rand(1,100);

//display numbers

echo $no1."+".$no2;

?>

//checking if submit button is clicked

if(isset($_REQUEST["submit"]))

{

//take users answer

$userans=$_REQUEST["userans"];

/umber1

$number1=$_REQUEST["no1"];

/umber2

$number2=$_REQUEST["no2"];

//addition

$total=$number1+$number2;

//checking answer

if($total==$userans)

{

//if correct answer display message

echo "Your Answer is CORRECT!";

}

else

{

//display message as wrong answer

echo "Your Answer is WRONG!";

}

}

?>

Warning: session_start: Cannot send session cookie headers already sent by (output started at /storage/ssd4/223/7123223/public_html/Mathtest.php:1) in /storage/ssd4/223/7123223/public_html/Mathtest.php on line 6 Warning: session_start): Cannot send session cache limiter - headers already sent (output started at /storage/ssd4/223/7123223/public_html/Mathtest.php:1) in /storage/ssd4/223/7123223/public_html/Mathtest.php on line 6 Notice: Undefined index: name in /storage/ssd4/223/7123223/public_html/Mathtest.php on line 42 Notice: Undefined index: email in /storage/ssd4/223/7123223/public_html/Mathtest.php on line 46 Welcome Your email address is: Here is your question: 16+11 submit Your Answer is WRONG

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!