我正在看关于制作博客,登录和注销的教程
在登录和注销系统后,我得到了一些错误
From Those Lines in this file
header。php
<?php ob_start();?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include "include/config.php";
global $tf_handle;
define("uid",$_COOKIE['uid']);
define("login",$_COOKIE['login']);
$QuerySelectU = mysqli_query($tf_handle,"SELECT * FROM user WHERE u_id ='".uid."'");
$FetchObjectU = mysqli_fetch_object($QuerySelectU);
#========================[USER]========================#
define("u_id",$FetchObjectU->u_id); // different because of cookies and Db
define("uname",$FetchObjectU->u_name);
define("uemail",$FetchObjectU->u_email);
#========================[USER]========================#
?>
的一部分index . php
<?php include"files/header.php";?>
<?php
global $tf_handle;
if(isset($_POST['login']))
{
$u_name = strip_tags($_POST['u_name']);
$u_pass = md5($_POST['u_pass']);
if(empty($u_name) or empty($u_pass))
{
echo"
<div class='error'>Please Fill the form</div><br />
";
}
else
{
$sqlquery = mysqli_query($tf_handle,"SELECT * FROM user WHERE u_name = '".$u_name."' AND u_pass = '".$u_pass."'");
if(mysqli_num_rows($sqlquery) > 0)
{
$fetchLquery = mysqli_fetch_object($sqlquery);
$uid = $fetchLquery->u_id;
$uname = $fetchLquery->u_name;
$upass = $fetchLquery->u_pass;
if($uname != $u_name AND $upass != $u_pass )
{
//AND $upass != $u_pass
echo"
<div class='error'>wrong information</div><br />
";
}
else
{
setcookie("uid",$uid,time()+60*60*24);
setcookie("login",1,time()+60*60*24);
echo"
<div class='error'>you be redirected to home page</div><br />
";
header("Refresh: 5; url=index.php");
}
}
else
{
echo"
<div class='error'>Wrong Information</div><br />
";
}
}
}
尝试打开index.php
i got some errors
注意:未定义的索引:uid在/var/www/html/blog/files/header.php第8行
注意:未定义的索引:login在/var/www/html/blog/files/header.php第13行
注意:试图获得非对象的属性在/var/www/html/blog/files/header.php的第18行
注意:试图获得非对象的属性在/var/www/html/blog/files/header.php的第19行
注意:试图获得非对象的属性在/var/www/html/blog/files/header.php的第20行
我在退出系统后得到了这些错误
Logout.php
<?php include"files/header.php";?>
<?php
if(login == 1)
{
setcookie("uid","",time()+60*60*24);
setcookie("login","",time()+60*60*24);
echo"
<div class='error'>Done </div><br />
";
header("Refresh: 5; url=index.php");
}
else
{
echo"
<div class='error'>Wrong Page </div><br />
";
}
?>
<?php include"files/block.php";?>
<?php include"files/footer.php";?>
您在登录后设置cookie,因此在登录之前,您没有提供cookie值。但是在index。php中,define
试图访问未设置的cookie值,这就是为什么它会显示错误cookie直到你登录时才设置,因此消息消失