Sometimes you need to use data collected in one quiz and pass that on to the next quiz.

Make use of Riddle’s custom result landing page feature for passing quiz data from one quiz to the next.

Here are some sample uses cases:

You might want to capture data in one quiz and re-use it in the next one for a user.

Maybe you’d like to string together quizzes and combine all of the results.

If so, this free course is for you.

I will also show you how to capture URL variables and how to combine them with data from the quiz.

Passing quiz data – key first step

Important: please make sure you understand how custom result landing pages work – and how to process data sent from a Riddle to a custom result page.

You can learn all this in this course on working with custom result landing pages.

Live example – passing data from one quiz to the next

You can check out the example yourself here on our Pastafun.com sample site (will open in a new tab). Make sure to go through the example once and pay close attention to the URL and the URL variables added to it in each step.

Capturing data from a quiz on a custom result landing page

Below is the code you need to capture the data from the first Riddle and pass it on to the landing page for that Riddle. Make sure to place this code on your server and link to it on the advanced tab in Riddle in the custom result landing page field.

<?php
session_start();

$riddle = json_decode($_REQUEST['data']);
$score = $riddle->resultData->scoreNumber;
$leadname = $riddle->lead2->Name->value;
$leademail =$riddle->lead2->Email->value;

$_SESSION['name'] = $leadname;
$_SESSION['email'] = $leademail;
$_SESSION['score'] = $score;

$redirectPage = "quiz1landing/?score=".$score;

?>
<script>
 window.parent.location.href = 'https://pastafun.com/<?php echo $redirectPage;?>';//change this to the URL of your blog.
</script>

Creating a button that launches a second quiz and passes data to the quiz via URL variables

Below is the code you need to create the button on the landing page of the first quiz.

The button is added to the page using the PHP Code WordPress Plugin from XYZ Code.

<?php
session_start();
$riddle_name = $_SESSION['name'];
$riddle_email = $_SESSION['email'];
$riddle1_score = $_SESSION['score'];
$redirectPage = "https://pastafun.com/quiz2start/?riddle1_score=".$riddle1_score."&riddle_email=".$riddle_email."&riddle_name=".$riddle_name;
echo '<a href="'.$redirectPage.'" class="myButton" style="box-shadow:inset 0px 1px 0px 0px #54a3f7;
	background:linear-gradient(to bottom, #007dc1 5%, #0061a7 100%);
	background-color:#007dc1;
	border-radius:3px;
	border:1px solid #124d77;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:Arial;
	font-size:13px;
	padding:6px 24px;
margin-left: 20%;
text-align: center;
	text-decoration:none;
	text-shadow:0px 1px 0px #154682;">Click here to start Quiz 2</a>';
?>

Capturing URL variables and processing them

Learn how to set up a Riddle form to capture hidden URL variables.

Use the form field “hidden URL query” for that. This will capture all URL variables and pass on the values of these variables along with all other Riddle data to the custom result page for Riddle 2.

Putting it all together on a final landing page combining the scores and data from 2 quizzes

This is the code for the second external PHP file, which captures and processes the data from the second Riddle, adds the scores together and passes all that one to the final result page.

<?php
session_start();

$riddle = json_decode($_REQUEST['data']);
$riddle1_score = $riddle->lead2->riddle1_score->value;
$riddle2_score = $riddle->resultData->scoreNumber;
$leadname = $riddle->lead2->riddle_name->value;
$leademail =$riddle->lead2->riddle_email->value;

$totalscore = intval($riddle1_score) + intval($riddle2_score);

$_SESSION['name'] = $leadname;
$_SESSION['email'] = $leademail;
$_SESSION['score'] = $totalscore;

$redirectPage = "final-quiz-result";



?>


?>
<script>
 window.parent.location.href = 'https://pastafun.com/<?php echo $redirectPage;?>';//change this to the URL of your blog.
</script>

The PHP snippet code for the final result page

<?php
session_start();
$riddle_name = urldecode($_SESSION['name']);
$riddle_email = $_SESSION['email'];
$total_score = $_SESSION['score'];
echo "Your name is ".$riddle_name." and your email is ".$riddle_email;
echo "<h3>Your result</h3><p>Tadaa. Your total score from both quizzes is: <strong>".$total_score."</strong>";

?>

Resources – passing data to quizzes

You can read more about our custom result pages on documentation. There you will find additional code samples that you can use to further customize this flow.

Of course you need an account to make your quiz on riddle.com. If you don’t have one yet, sign up for the 14 day free trial, which will allow you to build and test everything you learned in this course.

If you have any questions, sign in to riddle.com and use the chat box on the lower right side of the screen to talk to us.

Scroll to Top