当我提交表单时,我在login.php上登陆并出现很多错误。登录注销系统出错
我已经把错误以下链接: https://docs.google.com/document/d/1AqwZ71iAQgZGMU-W0Go6czbpgGenF_f7ucgmEFw0AHo/edit
我是新手,挣扎与上面的代码最后5小时。 我在我的登录注销系统以下页面:
db.php中
<?php
$conn=new mysqli('localhost','root','','people');
?>
的index.php
<?php
session_start();
?>
<html>
<head></head>
<body>
<form method="post" name="login" action="login.php">
<label for="name" class="labelname"> Username </label>
<input type="text" name="username" id="userid" required="required" /><br />
<label for="name" class="labelname"> Password </label>
<input type="password" name="password" id="passid" required="required" /><br />
<input type="submit" name="submit" id="submit" value="Login" />
</form>
</body>
</html>
的login.php
<?php
include('db.php');
session_start();
{
$user=mysqli_real_escape_string($_POST['username']);
$pass=mysqli_real_escape_string($_POST['password']);
$fetch=mysqli_query("SELECT id FROM `user` WHERE
username='$user' and password='$pass'");
$count=mysqli_num_rows($fetch);
if($count!="")
{
session_register("sessionusername");
$_SESSION['login_username']=$user;
header("Location:profile.php");
}
else
{
header('Location:index.php');
}}
?>
logout.php
<?php
session_start();
if(session_destroy())
{
header("Location: index.php");
}
?>
session.php文件
<?php
include('db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysqli_query("SELECT username FROM `user` WHERE username='$check' ");
$row=mysqli_fetch_array($session);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location:index.php");
}
?>
profile.php
<?php
include('db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysqli_query("SELECT username FROM `user` WHERE username='$check' ");
$row=mysqli_fetch_array($session);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location:index.php");
}
?>
嘿@ user3811050,谢谢你的问题。你能提供你得到的错误的细节吗?没有他们进行故障排除有点困难。谢谢! – yochannah
以明文存储密码是不可接受的。请不要为了您的用户的安全而这样做。 (Plain MD5/SHA1也不好,例如使用bcrypt或scrypt或AT至少是盐腌的SHA-256!) – ThiefMaster
@ThiefMaster,宝贝步骤。让我们先弄清楚如何做基本的PHP! – Aroll605