I am not sure why this is not working but what I am trying to say in the code below is that if the user is not logged in if ((!isset($username)) && (!isset($userid))){, then view the form else if they are logged in then display message stating they they must be logged out to view the page.
Problem is though is that even though the user is logged in, it still displays the form and not the message.
Below is the code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
include('member.php');
$user = (isset($_POST['user'])) ? $_POST['user'] : '';
$email = (isset($_POST['email'])) ? $_POST['email'] : '';
if ((!isset($username)) && (!isset($userid))){
echo "<form action='./forgotpass.php' method='post'>
<table>
<tr>
<td></td>
<td id='errormsg'>$errormsg</td>
</tr>
<tr>
<td>Username</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Email</td>
<td><input type='text' name='email' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='resetbtn' value='Reset Password' /></td>
</tr>
</table>
</form>";
}
else
{
echo "Please Logout to view this Page.";
}
?>
In top of the code above I am including the member.php page and I don’t know if this makes a big difference but the code for the member.php page is below:
<?php
if (isset($_SESSION['teacherforename'])) {
$_SESSION['teacherforename'] = $_SESSION['teacherforename'];
}
if (isset($_SESSION['teachersurname'])) {
$_SESSION['teachersurname'] = $_SESSION['teachersurname'];
}
if (isset($_SESSION['teacherid'])) {
$userid = $_SESSION['teacherid'];
}
if (isset($_SESSION['teacherusername'])) {
$username = $_SESSION['teacherusername'];
}
?>
check this you tried
the above will output the empty set it mean the $user and $email is set
to make it correct also use the
empty()correct one