Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php <br mode="hold" /?>session_start();
ob_start();

include("../config.php");
echo $count=$_SESSION['count']-1;
echo "  user name  ".$username=$_SESSION['username'];
echo "  user id  ".$userid=$_SESSION['userid'];
echo "  right  ".$right=$_SESSION['right'];
echo "  wrong  ".$wrong=$_SESSION['wrong'];
echo "  last attend  ".$lastattend=$_SESSION['questionattend'];
echo "  score  ".$score=($right/10)*100;
$result = mysql_query("SELECT * FROM scorecard WHERE register_id='".$userid."'"); 
      $row=mysql_fetch_array($result);
    
     
if($row['register_id']==NULL)
{
echo"  new row inserted    ";
mysql_query("INSERT INTO scorecard(register_id,count,last_attend,right_answer,wrong_answer,score) VALUES('$userid','$count','$lastattend','$right','$wrong','$score') ");
}
else
{
echo "    old row updated   ";
mysql_query(" UPDATE scorecard
SET count='$count', last_attend='$lastattend',right='$right',wrong='$wrong',score='$score'
WHERE register_id='$userid'");
}
   


//session_destroy();
//header("location:../online_test.php");

?>
Signin:
session_start();
include("../config.php");
if($_SESSION['userid']==NULL)
{
header("location:../online_test.php");
}

if(isset($_POST['submit']))
    { 
    echo $username=$_SESSION['username'];
    echo $userid=$_SESSION['userid'];
    $result = mysql_query("SELECT * FROM scorecard WHERE register_id='".$userid."'"); 
      $row=mysql_fetch_array($result);
     $row['register_id'];
     
if($row['register_id']==NULL)
      {
      echo "i am if loop";
      $_SESSION['count']=0;
    $category=$_POST[usercat];
    $_SESSION['category']=$category;
    
     $_SESSION['wrong']=0;
     $_SESSION['right']=0; 
      $result = mysql_query("SELECT * FROM online_category WHERE cat_id='".$category."'"); 
      $row=mysql_fetch_array($result);
      
      $result = mysql_query("SELECT * FROM quiz_edit_1  WHERE cat_id='".$category."' ORDER BY quiz_id"); 
     $rowno=mysql_num_rows ($result);
    
     $row=mysql_fetch_array($result);
    echo $_SESSION['question']=$row['quiz_id'];
      
     }
      else
      {
      echo "  i am else part  ";
      $category=$_POST[usercat];
    echo "  category  ".$_SESSION['category']=$category;
    echo "  count  ".$_SESSION['count']=$row['count'];
    echo "  wrong  ".$_SESSION['wrong']=$row['wrong_answer'];
     echo "  right  ".$_SESSION['right']=$row['right_answer']; 
    echo "  last attended   ".$lastattended=$row['last_attend']; 
    $result = mysql_query("SELECT * FROM quiz_edit_1  WHERE cat_id='".$category."' AND quiz_id='".$lastattended."' ORDER BY quiz_id"); 
     
    
     $row=mysql_fetch_array($result);
    echo $_SESSION['question']=$row['quiz_id'];
     }
Posted
Updated 27-Dec-11 18:21pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Dec-11 0:25am    
Why? And why do you think someone will be interested to sit down and re-write this code for you.
Better don't waste your time.

This is not a question.
--SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900