Try this code :
<?php
include 'left.php';
$conn = mysqli_connect('localhost','root','');
mysqli_select_db($conn, 'onlineexam');
if(isset($_POST['submit']) && !(isset($_SESSION['email'])))
{
session_start();
$_SESSION['email'] = $_POST['email'];
$_SESSION['pass'] = $_POST['password'];
$email = $_SESSION['email'];
$query = mysqli_query($conn, "select name,password,email from students where email = '$email'") or die("you are not registered");
$arr = mysqli_fetch_assoc($query);
if ($arr['password']==$_SESSION['pass'])
{
$name = $arr['name'];
echo "<div class="righttop">
<h1>hello $name</h1>
<form method='post' action='index.php'>
<input type='submit' name='logout' value='LOGOUT'>
</form>
</br></div>";
}
else
{
echo "<div class="righttop">
<h1>Wrong Password. Try Again!!</h1>
<?php include 'righttop.php'; ???>
</div>";
session_destroy();
session_cache_expire();
}
}
elseif(isset($_SESSION['email']))
{
echo "halaluuya";
}
else
{
header("Location: http://localhost/project/index.php");
exit();
}
include 'rightbottom.php';
?>
I have added another condition in the IF block as
if(isset($_POST['submit']) && !(isset($_SESSION['email'])))
Hope this will help you though I haven't tested it. Please let me know if you still find any issue or in case if it doesn't work.