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 8972047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:07:05+00:00 2026-06-15T18:07:05+00:00

I’m working on a personal project and part of the idea involves the user

  • 0

I’m working on a personal project and part of the idea involves the user answering five questions and, depending on the responses, it will navigate you to one of the 3 different stories. I am currently using a simple quiz from CSS-Tricks as a template and I’ve modified it to accept all answers as correct by using the elseif statement. The issue I have now is that I’m not entirely sure on how to make it point to one of the different files based on the responses.

The script works by asking questions (as you can see on the site, if you desire) which is output here, collected and displayed.

It’s relatively simple in that all the “A” answers point to one story, all the “B” answers point to another and the same for “C”. Obviously, due to the nature of the quiz I’m trying to edit, it wants to “grade” them rather than collect the results and make a decision based on that.

<?php

   $answer1 = $_POST['question-1-answers'];
   $answer2 = $_POST['question-2-answers'];
   $answer3 = $_POST['question-3-answers'];
   $answer4 = $_POST['question-4-answers'];
   $answer5 = $_POST['question-5-answers'];

   $responseA = 0;
   $responseB = 0;
   $responseC = 0;

   if ($answer1 == "A") { $responseA++; }
   elseif ($answer1 == "B") {$responseB++; }
   elseif ($answer1 == "C") {$responseC++; }

   if ($answer2 == "A") { $responseA++; }
   elseif ($answer2 == "B") {$responseB++; }
   elseif ($answer2 == "C") {$responseC++; }            

   if ($answer3 == "A") { $responseA++; }
   elseif ($answer3 == "B") {$responseB++; }
   elseif ($answer3 == "C") {$responseC++; }            

   if ($answer4 == "A") { $responseA++; }
   elseif ($answer4 == "B") {$responseB++; }
   elseif ($answer4 == "C") {$responseC++; }            

   if ($answer5 == "A") { $responseA++; }
   elseif ($answer5 == "B") {$responseB++; }
   elseif ($answer5 == "C") {$responseC++; }            

   if ($responseA) { echo '<a href="sin.php">Next Page</a>'; }
   elseif ($responseB) { echo '<a href="mys.php">Next Page</a>'; }
   elseif ($responseC) { echo '<a href="ils.php">Next Page</a>'; }

?>

So, if anybody could point me in the right direction, I’d appreciate it. It sounded simple enough when I thought it up but it’s far trickier than I planned for a learning project!

EDIT

I’ve updated the code to reflect cbronson’s suggestions and it certainly works a lot better than before! The problem I have now is that it seems responseC is not being counted. The first two variable’s are working perfectly and any combination of those will result in A or B but when I select even all C, it spits out the link to “mys.php” rather than with “ils.php”.

EDIT 2

Got it working again. Silly, silly, silly. Thanks for all your help!

  • 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-06-15T18:07:06+00:00Added an answer on June 15, 2026 at 6:07 pm

    Instead of a single response variable, create three separate variables for each answer (A,B,& C) and add one to each var respective of the test results. Then whichever response variable has more results (was chosen most frequently), will be your overall answer. Tie breaking will be up to you.

    For example, if I answer the quiz with: 1)A 2)B 3)C 4)A 5)A; The variables should be: responseA = 3, responseB = 1, responseC = 1. Variable response A is greater than B and C so point me to the story for response A.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I need to clean up various Word 'smart' characters in user input, including but

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.