我不确定为什么这不起作用,但我想在下面的代码中说的是,如果用户未登录if ((!isset($username)) && (!isset($userid))){
,则查看其他表单(如果他们已登录),然后显示消息说明他们必须注销查看页面。
问题是即使用户登录,它仍然显示表单而不是消息。
下面是代码:
<?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.";
}
?>
在上面的代码中,我包含了 member.php 页面,我不知道这是否有很大的不同,但 member.php 页面的代码如下:
<?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'];
}
?>