<?php 
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome</title>
<link rel="stylesheet" type="text/css" href="css/styleindex.css" />

</head>

<body>
<?php 
//session_start();
//echo "<div align=center><h2><font color=#ffffff><blink>".$_SESSION['error']."</blink></font></h2></div>";
?>

<form method="post" action="index.php">
<table cellpadding="10"><tr><td colspan="2">Enter Your Username and Password<hr /></td></tr>
		<tr><td width="96">Username</td>
		<td width="229"><input type="text" name="uname" /></td></tr>
		<tr><td>Password</td><td><input type="text" name="psw" /></td></tr>
		<tr><td colspan="2"><center><button name="login" value="login">Start Exam</button></center></td></tr>
</table>
</form>


<p>
  <?php 


?>
<?php
if (isset($_POST['login'])){ 
$sname=strtoupper($_POST['uname']);
$oname=strtoupper($_POST['psw']);
$fname=$sname." ".$oname;
session_start();
$_SESSION['login']=$sname; 
$_SESSION['login2']=$fname; 
if(empty($_SESSION['login']))
{$_SESSION['error']="Either Field cannot be Empty";

header("location:index.php");}
else {
//echo "<div align=right><font color=#ffffff><H3>WELCOME &nbsp;".$fname."</H3></font></div>";
//code to create quiz_taker table 

$servername = "localhost";
$username = "root";
$password = "";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
else{
// Create database
$link = mysqli_connect("localhost", "root", "", "cbt");
$sql2= "CREATE TABLE `$sname` (
  `id` int(11) NOT NULL auto_increment,
  `qst` varchar(50) NOT NULL,
  `chosen` varchar(50) NOT NULL,
  `correct` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3";
//end 
}
mysqli_query($link, $sql2);
header("location:cbt2.php");
}
}
?>
</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
<center><form action="index.php"><button name=ls value=ls>CLICK TO GE BACK TO LESSON AREA</button></form></center>

</body>
</html>
