my index.php page looks like
<?php include("header.php");
$nameerror = $courseerror = "";
if($_SERVER['REQUEST_METHOD'] == "POST"){
if(isset($_POST['name']) && !empty($_POST['name'])){
$name = $_POST['name'];
}else{
$nameerror = "Please Enter Your Name And Continue";
}
if(isset($_POST['course']) && !empty($_POST['course'])){
$course = $_POST['course'];
}else{
$courseerror = "Please Select Your Course And Continue";
}
if(isset($name) && isset($course)){
$_SESSION['name'] = $name;
$_SESSION['course'] = $course;
header("Location: questions.php");
}
}
?>
<table>
<caption><?php echo $nameerror."<br>".$courseerror; ?></caption>
<form action="index.php" method="post">
<tr><td><label for="name"> Name </label> </td><td><input type="text" id="name" name="stname"></td></tr>
<tr><td valign="top"><label for="course"> Course </label> </td><td>
<select name="course">
<option value="acit"> Acit </option>
<option value="graphics"> Graphics </option>
<option value="networking"> Networking </option>
<option value="programming"> Programming </option>
<option value="adit"> Adit </option>
</select>
</td></tr>
<tr> <td colspan="2" ><input type="submit" value="Continue" </td> </tr>
</form>
</table>
<?php include("footer.php"); ?>
but the problem is when i use header function to redirect it to my questions.php page it wont redirect to questions.php it loads the same index.php page again and nothing else here is the code from above
if(isset($name) && isset($course)){
$_SESSION['name'] = $name;
$_SESSION['course'] = $course;
header("Location: questions.php");
}
}
and my header page look like this. so whats wrong here i cant get it ?
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Pearl Institute Of Information Technology Online Examination</title>
<link href="css/main.css" rel="stylesheet">
</head>
<body>
<div id="main">
<header>
<img src="images/logo.png">
<h1> Pearl Institute Online Examination System </h1>
</header>
<div id="content">