且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用php将值从一个页面调用到另一个页面?

更新时间:2023-01-08 11:40:23

_SESSION [ ' name'])){


right_answer = 0;


wrong_answer = 0;

Hi all,

I'm creating one quiz application using php and into that I've create one result page which displays the score details about the user and a button to print the certificate. Actually what I need is i need to get the user information in one page like their name, mail id, mbl number, score and print them into another page.

And my code is,

<?php 
require 'config.php';
if(!empty($_SESSION['name'])){
    
    $right_answer=0;
    $wrong_answer=0;
    $unanswered=0; 
  
   $keys=array_keys($_POST);
   $order=join(",",$keys);
   
   //$query="select * from questions id IN($order) ORDER BY FIELD(id,$order)";
  // echo $query;exit;
   
   $response=mysql_query("select id,answer from questions where id IN($order) ORDER BY FIELD(id,$order)")   or die(mysql_error());
   
   while($result=mysql_fetch_array($response)){
       if($result['answer']==$_POST[$result['id']]){
               $right_answer++;
           }else if($_POST[$result['id']]==5){
               $unanswered++;
           }
           else{
               $wrong_answer++;
           }
   }
   $name=$_SESSION['name'];  
   mysql_query("update users set score='$right_answer' where user_name='$name'");
?>


<a href="test11.php" class='btn btn-success'>Get Certificate</a>
                  
                       <div style="margin-removed 30%">
                        <p>Total no. of right answers : <span class="answer"><?php echo $right_answer;?></span></p>
                        <p>Total no. of wrong answers : <span class="answer"><?php echo $wrong_answer;?></span></p>
                        <p>Total no. of Unanswered Questions : <span class="answer"><?php echo $unanswered;?></span></p>                   
                       </div> 



In this code I need to get the value of $right_answer and post that into,

<tr>
		<p><td>Score </td>
		<td name="score"><!--Post the score value Here--></td></p>
</tr>




Anyone help me to do this..


Thanks in advance,
Priya

_SESSION['name'])){


right_answer=0;


wrong_answer=0;