我是编程初学者,我评论了我不理解代码的行。并且与数据库的连接正常,所以我不明白为什么它不起作用。
这里是 LOGIN.PHP
<?php
include("connectiondbs.php");
include("javascript.js");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$u=$_POST['username'];
$p=$_POST['password'];
$sql="SELECT userID FROM users WHERE login='$u' and password='$p'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active']; //I AM NOT SURE ABOUT THIS ONE
$count=mysql_num_rows($result);
if($count==1)
{
session_register("username");
session_register("password"); //HAS TO BE THE PASSWORD IN REGISTER?
$_SESSION['login_user']=$u;
header("location:succesfulllogin.php"); // HAS TO BE THIS FILE? OR I CAN GO TO THE MENU.HTML RIGHT NOW
}
else {
echo "Wrong Username or Password";
}}
?>
<form action="" method="post">
<label>Login :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>
JAVASCRIPT.JS
<script Language="JavaScript">
<!--
function check_empty_field()
{
if (form.username.value == "" || form.password.value == "")
{
alert("Please fill in the password or login field.");
return (false);
}
return (true);
}
-->
</script>
成功登录.php
<?php
session_start();
if(!session_is_registered(username)){
header("location:login.php");
}
else{
header ("location:menu.html");
}
?>