First of all, let me explain how my system works. I create the homepage of system using standard php. But, to display the online quiz, i am using a framework which is PHP CI. I've problems when the user completely answer the online question, i need to redirect them to homepage. However, i can't do that because of different medium used which is between standard PHP and PHP CI.
Let me show you what I currently doing. result_display.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<body>
<div id="container">
<h1>Welcome to Online Examination</h1>
<?php $score =0; ?>
<?php $array1 = array(); ?>
<?php $array2 = array(); ?>
<?php $array3 = array(); ?>
<?php $array4 = array(); ?>
<?php $array5 = array(); ?>
<?php $array6 = array(); ?>
<?php $array7 = array(); ?>
<?php $array8 = array(); ?>
<?php $array9 = array(); ?>
<?php foreach($checks as $checkans) { ?>
<?php array_push($array1, $checkans); } ?>
<?php foreach($results as $res) { ?>
<?php array_push($array2, $res->answer);
array_push($array3, $res->quizID);
array_push($array4, $res->question1);
array_push($array5, $res->choice1);
array_push($array6, $res->choice2);
array_push($array7, $res->choice3);
array_push($array8, $res->choice4);
array_push($array9, $res->answer);
} ?>
<?php
for ($x=0; $x <11; $x++) { ?>
<form method="post" action="<?php echo base_url();?>index.php/Questions/resultdisplay">
<p><?=$array3[$x]?>.<?=$array4[$x]?></p>
<?php if ($array2[$x]!= $array1[$x]) { ?>
<p><span style="background-color: #FF9C9E"><?=$array1[$x]?></span></p>
<p><span style="background-color: #ADFF84"><?=$array2[$x]?></span></p>
<?php } else { ?>
<p><span style="background-color: #FF9C9E"><?=$array1[$x]?></span></p>
<?php $score = $score + 1; ?>
<?php } } ?>
<br>
<h2>Your Result: </h2>
<h1><?=$score?>/11</h1>
<br><br>
<a href="homepage.php">Back to Homepage
</form>
</div>
</body>
</html>
The link which is Back to Homepage could not redirect user back to homepage. Is anybody knows how to code it well ? Thanks in advance.
Close the anchor tag like this
<a href="homepage.php">Back to Homepage</a>
The missing bit ^^^^
Or in Codeigniter code I would expect to see something like this,
<a href='<?php echo base_url('<controllername>'); ?>'>Back to Homepage</a>
Homepage
Problem : Back to Homepage
In your piece of code You can't close anchor tag so it's can't be redirected.
For simply back to previous page use this
First load this library
$this->load->library('user_agent');
And then use this
redirect($this->agent->referrer());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.