我有一个登录页面,要求用户登录详细信息将其发送到cookie然后验证详细信息但由于某种原因它不允许我登录。如果我在我的计算机上安装的abyss webserver本地测试它工作正常,但如果我在我的托管服务器上测试它不起作用,这是我的代码:
一旦选择了登录页面就会这样工作它会询问详细信息然后如果用户未被激活则要求激活用户如果用户被激活则登录工作但是一旦用户被激活不是它不会比激活请求继续下去。
登录问:
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cont=true&loginUSER=true" style="font-family:Calibri;">
<fieldset style="border-style:none">
<p>
Email: <input style="position:absolute; left:30%;" onkeyup="javascript: this.value=this.value.toLowerCase();" class="details" type="text" name="email" id="email" />
</p>
<p>
Password: <input style="position:absolute; left:30%;" class="details" type="password" name="password" id="password" />
</p>
<input type="submit" value="login" class="btn" style="background-color:#FFF; border-style:solid; border-width:thin; font-family:Calibri;" />
</fieldset>
</form>
如果没有cookie,那么它首先检查登录,然后确定是否存在
//A new login first create cookies and check if they are valid
if(!isset($_COOKIE["thebillboard"]))
{
//Don't allow user to login if this is not true;
$thisIsValid = false;
//set cookies for login details entered!
$email = $_POST["email"];
$pass = $_POST["password"];
setcookie("thebillboard",$email,time()+3600);
setcookie("password",$pass,time()+3600);
//check if the login details exists
$clients = mysql_query("SELECT * FROM clients");
while($row = mysql_fetch_array($clients))
{
if(($row["businessEmail"] == $email) && ($row["password"]) == $pass)
{
$thisIsValid = true;
break;
}
}
}
//If the cookies exists check if they are valid
elseif(isset($_COOKIE["thebillboard"]))
{
//Don't allow user to login if this is not true;
$thisIsValid = false;
//get cookies for login if it exists!
$email = $_COOKIE["thebillboard"];
$pass = $_COOKIE["password"];
//check if the login details exists
$thisIsValid = false;
$clients = mysql_query("SELECT * FROM clients");
while($row = mysql_fetch_array($clients))
{
if(($row["businessEmail"] == $email) && ($row["password"] == $pass))
{
$thisIsValid = true;
break;
}
}
然后如果变量$ thisIsValid为true,它会继续显示登录用户,否则它会在登录详细信息中返回错误
答案 0 :(得分:0)
如果使用Chrome,您可以安装此附加组件,它可以帮助您查看与活动网站相关联的Cookie:https://chrome.google.com/webstore/detail/edit-this-cookie/fngmhnnpilhplaeedifhccceomclgfbg?hl=en
从这里你应该能够推断出出现了什么问题(如果它与cookie有关)。
答案 1 :(得分:0)
您可以在没有插件的情况下调试cookie。 在脚本结束时,将标题重定向放到空白页面。
header("Location: /debug.php");
在degub.php中,只需要执行print_r($ _ COOKIE)并查看包含的内容。
注意:我并不真正关心此重定向中可能出现的错误标题 - 它仅用于调试目的,所以请不要对此进行评论。