<?php
session_start();
include('connect.php');
$sql=mysql_fetch_array(mysql_query("select * from users 
where id='$_SESSION[user_id]'"));
echo 'welcome to  '.' '.$sql['name'];
?>
<form method="post" action="">
<?php
$sql=mysql_query("select * from questions where exam_id='$_GET[id]'");
$i=1;

while($row=mysql_fetch_array($sql))
{
$y=$row['name'];
echo 'q'.$i.'  :';
echo $row['question'];
echo '<br>';
echo '
<input type="radio" name="'.$y.'" valuse="'.$row['choice1'].'">'.$row['choice1'].'
<input type="radio" name="'.$y.'" valuse="'.$row['choice2'].'">'.$row['choice2'].'
<input type="radio" name="'.$y.'" valuse="'.$row['choice3'].'">'.$row['choice3'].'
<input type="radio" name="'.$y.'" valuse="'.$row['choice4'].'">'.$row['choice4'].'
<br>
<br>
<hr>';

$i++;

}
?>
<input type="submit" name="ok" value="    ok    ">
</form>

<?php
if($_POST['ok'])
{
$e=$_POST['$y'];

$s=mysql_fetch_array(mysql_query("select * from examname 
where id='$_GET[id]'"));

$ww=mysql_query("select * from questions 
where exam_id='$_GET[id]'");

while($row=mysql_fetch_array($ww))
{

if($e==$row['correct_choice'])
{
$mark=$mark+$row['mark'];
}

}
echo 'mark = '.$mark;
include('disconnect.php');
}

?>