PHP:登录错误
我是PHP的新手。目前我正在登录。我这样说是错误的 注意:未定义索引:第4行C:\xampp\htdocs\checkbox\admin.php中的用户 不客气” 但是“用户”已经存在于我的prcess_login.php中 下面是我的main_login.php代码PHP:登录错误,php,login,undefined,Php,Login,Undefined,我是PHP的新手。目前我正在登录。我这样说是错误的 注意:未定义索引:第4行C:\xampp\htdocs\checkbox\admin.php中的用户 不客气” 但是“用户”已经存在于我的prcess_login.php中 下面是我的main_login.php代码 Username :<input type="text" id="userID"name="username"><br/><br/> Password : <input type="pa
Username :<input type="text" id="userID"name="username"><br/><br/>
Password : <input type="password" id="passID"name="password">
<input type="image" name="btnLogin" src="image/btnLogin.png" value="SignIn" onClick="this.form.action='process_login.php'; this.form.submit()">
<?php
include("connect.php");
$username = $_POST["username"]; //Storing username in $username variable.
$password = $_POST["password"]; //Storing password in $password variable.
$match = "SELECT * from tblmembers WHERE fldUsername = '".$_POST['username']."' AND fldPassword = '".$_POST['password']."';";
$qry = mysql_query($match);
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "Sorry, there is no username $username with the specified password.";
echo "Try again";
exit;
} else {
$_SESSION['user']= $_POST["username"];
header("location:admin.php");
}
?>
用户名:
密码:
接下来是我的流程_login.php
Username :<input type="text" id="userID"name="username"><br/><br/>
Password : <input type="password" id="passID"name="password">
<input type="image" name="btnLogin" src="image/btnLogin.png" value="SignIn" onClick="this.form.action='process_login.php'; this.form.submit()">
<?php
include("connect.php");
$username = $_POST["username"]; //Storing username in $username variable.
$password = $_POST["password"]; //Storing password in $password variable.
$match = "SELECT * from tblmembers WHERE fldUsername = '".$_POST['username']."' AND fldPassword = '".$_POST['password']."';";
$qry = mysql_query($match);
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "Sorry, there is no username $username with the specified password.";
echo "Try again";
exit;
} else {
$_SESSION['user']= $_POST["username"];
header("location:admin.php");
}
?>
最后是admin.php
<?php
include("connect.php");
session_start();
echo "You are Welcome ". $_SESSION['user'];
?>
在admin.php中出现错误…我只是在这里复制了这些代码
- 我不明白为什么在我的进程中没有“用户”_login.php
请帮帮我。。。谢谢你Session\u开始php标记后的第一行。使用Session\u start();在“my process_login.php”的顶部,因为没有正在启动的会话,在admin.php中也是如此。。会话_start()应该在任何代码之前位于页面顶部。请不要在不知道粘贴代码在处理用户信息时的作用的情况下复制粘贴代码。您的代码使用的是不推荐使用的数据库api,易受sql注入攻击,并以纯文本形式存储密码。除此之外,您的代码也容易受到XSS攻击。请注意,不是错误,请将其粘贴到文件前面:error|u reporting(E|u error | E|u WARNING | E|u PARSE);还缺少会话_start()@米海..谢谢...)我不会忘记你说的话