Php 我必须点击提交按钮两次才能登录
我正在使用php登录一个用户,下面是处理该过程的代码,问题是一旦我提供用户名和密码,我必须单击两次登录按钮才能登录,第一次单击时,页面只需重新加载第二次单击时,脚本会将我发送到面板这是代码如果我能获得一些帮助,那将很好:Php 我必须点击提交按钮两次才能登录,php,html,forms,login,Php,Html,Forms,Login,我正在使用php登录一个用户,下面是处理该过程的代码,问题是一旦我提供用户名和密码,我必须单击两次登录按钮才能登录,第一次单击时,页面只需重新加载第二次单击时,脚本会将我发送到面板这是代码如果我能获得一些帮助,那将很好: enter code here <?php require_once 'core/init.php'; if(input::exists()) { if(token::check(input::get('token'))) { $user = new us
enter code here
<?php
require_once 'core/init.php';
if(input::exists()) {
if(token::check(input::get('token'))) {
$user = new user();
$remember = (input::get('remember') === 'on') ? true : false;
$login = $user->login(input::get('uname'), input::get('password'), $remember);
if($login) {
redirect::to('panel.php');
} else {
echo '<p>Sorry, that username and password wasn\'t recognised.</p>';
}
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Storon Management System</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--<link rel="stylesheet" type="text/css" href="FlatUI/css/flatui.css">-->
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css family=Oxygen'>
<script type="text/javascript" src="js/fade.js"></script>
</head>
<body>
<div class="offerboxlog">
<?php include "includes/logo.php"; ?>
<h2>Under Construction..</h2>
<ul>
<li>Business Performance Insights</li>
<li>Book Management </li>
<li>Customer Management</li>
</ul>
<a href="register.php">Register For An Account</a>
</div>
<div id="loginf">
<div id="lform">
<h3>Login</h3><br>
<form action="" method="post">
<div class="field212">
<label for="uname">Username</label><br/>
<input type="text" name="uname" id="uname" class="login-form"><br>
</div><br/>
<div class="field212">
<label for="password">Password</label><br/>
<input type="password" name="password" id="password" class="login-form">
</div><br/>
<div class="field212">
<label for="remember">
<input type="checkbox" name="remember" id="remember"> Remember me
</label>
</div><br/>
<input type="submit" value="Log in" name="login" />
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>" />
</form>
</div>
</div>
</body>
</html>
public function login($username = null, $password = null, $remember = false) {
if(!$username && !$password && $this->exists()) {
session::put($this->_sessionName, $this->data()->id);
} else {
$user = $this->find($username);
if($user) {
if($this->data()->password === hash::make($password, $this->data()->salt)) {
session::put($this->_sessionName, $this->data()->id);
if($remember) {
$hash = hash::unique();
$hashCheck = $this->_db->get('users_session', array('user_id', '=', $this- >data()->id));
if(!$hashCheck->count()) {
$this->_db->insert('users_session', array(
'user_id' => $this->data()->id,
'hash' => $hash
));
} else {
$hash = $hashCheck->first()->hash;
}
Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));
}
return true;
}
}
}
return false;
}
我们可以看到登录的方法吗?也许它不是真的,或者有什么不对劲,看看当你点击一个按钮两次调用函数时会发生什么。