【发布时间】:2015-04-05 17:00:07
【问题描述】:
我有两个页面 login.php 和 user.php(其中消息 = 错误组合,我一个回应他的)试图在 login.php 中显示一条消息,该消息来自 user.php,基于错误组合电子邮件和密码请如何在我的 login.php 中显示消息下面是我的代码
下面的user.php页面
class Users {
function login($find='') {
if(($rows["email"] == $email)&&($rows["password"] == $password)){
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
if (isset($_POST['remember'])){
setcookie("cookname", $_SESSION['email'], time()+60*60*24*100, "/");
setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100, "/");
}
$_SESSION['user_id'] = $user_id;
return true;
}
else {
$message = 'Wrong Combination';
return false;
}
}
}
下面的login.php页面
<?php
include_once("user.php");
if (isset($_POST['submit']))
{
$find = $user->login($_POST);
if ($find)
{
header ("location: panel.php");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<form name="form1" method="post" action="">
<!-- I want to echo it here I echo the variable message but did not work -->
<?php echo "$message";?>
input id="email" />
<input id="password" />
</form>
</body>
</html>
【问题讨论】:
-
在另一个主题上,将用户登录凭据存储在 cookie 中是一个安全漏洞。我建议通读整个 owasp.org PHP 安全备忘单以获得很好的概述。以下是与“记住我”cookie 相关的内容:owasp.org/index.php/PHP_Security_Cheat_Sheet#Remember_Me
标签: php function echo inner-classes