这是我的 login.php
<form action="index.php" method=get>
<?php
error_reporting(E_ALL & ~E_NOTICE);
?>
<?php
session_start();
if( $_SESSION["logging"]&& $_SESSION["logged"])
{
printme(); }
else {
if(!$_SESSION["logging"])
{
$_SESSION["logging"]=true;
loginform();
}
else if($_SESSION["logging"])
{
$number_of_rows=checkpass();
if($number_of_rows==1)
{
$_SESSION[user]=$_GET[userlogin];
$_SESSION[logged]=true;
echo "<h1>You have logged in successfully</h1><br/>";
echo "<a href='logout.php'>Logout</a> | <a href='users.php'>Click to proceed</a>";
}
else {
loginform();
}
}
}
function loginform()
{
print ("<center><div id='login_header'><b><font face='Arial Black' color='black' size='4px'>Sign in to Minquep!</font></b></div></cen ter>");
print("<br/><br/>");
print ("<center><label>Username:</label><input type='text' name='userlogin' size='20'><br/><label>Password:</label><input type=' password' name='password' size='20'></center>");
print "<br/><input type='submit' value='Submit' name='submit' class='submit'>";
}
function checkpass()
{
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbname = 'minquep_test';
$conn = mysql_connect($dbHost,$dbUser,$dbPass); // Connection Code
mysql_select_db($dbname,$conn); // Connects to database
$sql = "select * from users where login='$_GET[userlogin]' and password='$_GET[password]'";
$result = mysql_query($sql,$conn) or die(mysql_error());
$fetched = mysql_fetch_array($result);
if ($fetched['user_type'] == "moderator"){
echo '<script type="text/javascript">window.alert("You have logged in successfully!\n")</script>';
echo "Welcome {$_SESSION['user']}";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=pages/moderator.php\">";
}
if ($fetched['user_type'] == "agent"){
echo '<script type="text/javascript">window.alert("You have logged in successfully!\n")</script>';
echo "<meta http-equiv=\"refresh\" content=\"0;URL=pages/agent.php\">";
}
}
function content(){
print("<b><h1>hi mr.$_SESSION[user]</h1>");
print "<br><h2>only a logged in user can see this</h2>";
}
function printme(){
echo '<script type="text/javascript">window.alert("You have logged in successfully!\n")</script>';
}
?>
</form>
现在,每当用户登录...如果他的 user_type 是“主持人”,他将被重定向到 moderator.php
如果他的 user_type 是“agent”,他将被重定向到 agent.php
我想要发生的是在用户将被重定向到的页面中输出用户名和用户类型。
这就是我的 agent.php 和 moderator.php
<?php session_start();
echo "Welcome {$_SESSION['user']} . And You are Logged in as /*USER TYPE SHOULD BE DISPLAYED HERE */ ";
?>
我收到此错误: