我有一个登录表单,当我尝试登录但失败时,我被发送回登录表单并且它是空白的。我想在尝试失败时保留用户名/电子邮件地址字段,以便我只需要再次输入密码。关于我需要做什么的任何建议?
HTML:
<?php if ($_GET['msg'] == 'failed') : ?>
<p style="color:red; font-weight: bold">Incorrect email or password. Try again!</p>
<?php endif; ?>
<form action="index.php?cmd=login" method="post" id="form">
<div class="signup-form">
<p>
<label>Email</label>
<input type="text" name="email" value="" class="textbox required email" />
</p>
<p>
<label>Password</label>
<input type="password" name="password" value="" class="textbox required"/>
</p>
<p>
<label></label>
<input type="checkbox" name="rememberme" value="1" class="" checked="checked" /> Remember Me?
</p>
<p>
<a style="margin: 10px 0 0 0; color:#000;" class="button" href="javascript://" onclick="$('#form').submit()">Continue</a> <img src="images/ajax-loader.gif" class="loading" style="display: none;" />
和:
if ($_POST) {
$login = $_USER->do_log_in(input($_POST['email']), md5($_POST['password']), $_POST['rememberme']);
if ($login == true) {
$_SESSION['userid'] = $_USER->get_user_id();
header('location: index.php');
}else
header('location: index.php?cmd=login&msg=failed');
}