在php-mysql中建立登录-注销会话时出现服务器错误


server error coming while establishing login logout session in php mysql

我从一个网站获得了帮助,并使用了他们的大部分代码。我理解代码,但无法找出错误。

//main_login.php

<html>
<title>User Login Form</title>
<head></head>
<body>
<form name="form1" method="post" action="newcheckLogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="80">Username</td>
<td width="6">:</td>
<td width="300"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td width="6">:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>

//newchecklogin.php-用于检查用户和查询数据库。

    <?php
    include("config.php");
    session_start();
    #echo "Check Login'n";
    ?>
    <html>
    <head><title></title>
    <form name="form2" method="post" action="Logout.php">
    <p align="right">
    <input type="submit" name="Logout" id=Logout" >
    </p>
    </form>
    </head>
    </html>
    <?php
    $myusername=stripslashes(mysql_real_escape_string($_POST['myusername']));
    $mypassword=md5(stripslashes(mysql_real_escape_string($_POST['mypassword'])));
    $sql="select jobid from jobs where userID='$myusername'";
    echo "Hey ".$myusername." ";
    $result=mysql_query($sql) or die(mysql_error());
    $row=mysql_fetch_array($result);
    $active=$row['active'];
    if(mysql_num_rows($result)==1){
            echo "Username and password found";
            session_register("myusername");            
            $_SESSION['login_user']=$myusername;           
            header("location:welcome.php");
    }
    else{
            $error="Your login Name or Password is invalid";
    }
    ?>

//welcome.php

<?php
include('lock.php');
include('newchecklogin.php');
?>
<body>
<h1>Hello <?php echo $login_session; ?></h1>
<?php
echo "<br>You have ".$mysql_num_rows($result)." jobs<br>";
echo "<table border=1 cellpadding=4><th>Job id</th><br>";
while ( $r = mysql_fetch_assoc($result) ) {
        echo "<tr><td>";
        echo $r['jobid']."</td></tr>";
}
echo "</table>";
?>
</body>

//lock.php

<?php
include('config.php');
session_start();
$user_check=$_Session['login_user'];
$ses_sql=mysql_query("select userID from jobs where userID='$user_check'");
$row=mysql_fetch_array($ses_sql);
$login_session=$row['userID'];
if(!isset($login_session)){
        header("Location:login.php");
}
?>

请帮忙,如果有人能再次向我解释如何安排会议,那就太好了。

我认为问题是,您已经命名了lock.php文件,并且在尝试登录后试图重定向login.php