Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:20:01+00:00 2026-05-26T20:20:01+00:00

First of all, I just started PHP. I know my methods might not be

  • 0

First of all, I just started PHP. I know my methods might not be the most efficient, but please try to remember that I’m new to all of this. Examples work great.

I’m trying to write a simple php code for that asks the user three questions. One true/false, one multiple choice and one short answer. Each question is displayed on its own page.

When I try to run this, I get the following error:

 Error: Deprecated: Function session_is_registered() is deprecated on line 10

This script still runs with this error. The problem though is at the end of the quiz, the variable $correct does not seem to change. I printed the variable to see if it was changing and nothing gets printed so obviously something is wrong — possibly the deprecated function error is the culprit.

Any help would be appreciated.

<?php
ini_set('session.gc_maxlifetime',900);
//echo ini_get("session.gc_maxlifetime"); 
session_start();
if($_SESSION['loggedin'] !== 1) {
header('Location: login.php');
exit;
}

if (!session_is_registered("loggedin"))
{
 $_SESSION["number"] = 0;
 $_SESSION["correct"] = 0;
}

$total_number = 3;

print <<<TOP
<html>
<head>
<title> History Quiz </title>
</head>
<body>
<h3> History Quiz </h3>
TOP;

$number = $_SESSION["number"];
$correct = $_SESSION["correct"];


if ($number == 0){
print <<<FIRST
<p> You will be given $total_number questions in this quiz. <br /><br/>
  You will have 15 minutes to complete it. <br /><br/>
  You cannot go back to change previous answers.<br /><br/>
  Here is your first question: <br /><br />
</p>
<p>1. Abe Lincoln was born in Illinois.</p>
<p>
    <label><input type="radio" name="question1" value="true" /> True </label>
    <label><input type="radio" name="question1" value="false" /> False </label>
</p>
FIRST;

if (isset($_POST['submit'])) {

$selected_radio = $_POST['question1'];

if ($selected_radio == 'false') {
   $correct++;
   $_SESSION["correct"] = $correct;
   print $correct;
}
}
}


if ($number == 1){
print <<<SECOND
<p>2. In what state was the battle of Gettysburg fought?</p>
<p>
    <label><input type="checkbox" name="question2" value="Texas" /> a) Texas </label><br/>
    <label><input type="checkbox" name="question2" value="Pennsylvania" /> b) Pennsylvania   
 </label><br/>
    <label><input type="checkbox" name="question2" value="Virginia" /> c) Virginia </label><br/>
    <label><input type="checkbox" name="question2" value="West Virginia" /> d) West Virginia     
 </label>
</p>
SECOND;

if (isset($_POST['submit'])) {

$selected_checkbox = $_POST['question2'];

if ($selected_checkbox == 'Pennslyvania') {
   $correct++;
   $_SESSION["correct"] = $correct;
   print $correct;
}
}
}


if ($number == 2){
print <<<THIRD
<p>3. The last name of the commander of the Army of North Virginia was __________.</p>
<p>
    <input type='text' id='question3' />
THIRD;

if (isset($_POST['submit'])) {

$selected_answer = $_POST['question3'];

if ($selected_answer == "lee") {
   $correct++;
   $_SESSION["correct"] = $correct;
}
}
}


if ($number >= $total_number)
{
print <<<FINAL_SCORE
Your final score is $correct correct out of $total_number. <br /><br />
Thank you for playing. <br /><br />
FINAL_SCORE;
session_destroy();
}
else
{
$number++;
$_SESSION["number"] = $number;
$script = $_SERVER['PHP_SELF'];
print <<<FORM
<form method = "post" action = $script>
<input type = "submit" value = "Check Answer" />
</form>
FORM;
}

print <<<BOTTOM
</body>
</html>
BOTTOM;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:20:01+00:00Added an answer on May 26, 2026 at 8:20 pm

    function session_is_registered() is depcrecated, just use something like isset($_SESSION['blah']) to check

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started working on my first Visual Studio project, and I imported all
First of all, do not be overwhelmed by the long code, I just put
First of all, I know how to build a Java application. But I have
First of all: I am not an experienced ClearCase user, but I have lots
First of all there is a partial question regarding this, but it is not
I have just started learning PHP, and here's my first doubt... Both of these
First of all I'm new to the C# world. I just started this year
First of all I want to state that I've just started with Drupal so
When my team first started out with SVN we all just used our first
First of all, im new here, and im (not) a pro ;) (but i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.