0
我想创建一个登录名和我有一些问题。当我登录我的代码时会提示我进行身份验证(因为它应该如果我输入了错误的密码),但是现在我已将密码硬编码。即使当我输入正确的密码时,也没有打开链接,所以我可以访问该页面。PHP登录表单发出
注意下面我的代码:
网站配置文件
<?php
define('WEB_ROOT' , '/mjcrawle/bank/');
define('ABSOLUTE_PATH' , '/home/mjcrawle/main/bank/');
define('URL_ROOT' , 'http://tomcat.cit.iupui.edu/mjcrawle/main/');
define('APP_ROOT' , 'http://tomcat.cit.iupui.edu/mjcrawle/main/bank/');
?>
登录进程文件
<?php
/*Required Fields*/
require_once('websiteconfig.inc.php');
/*FUNCTIONS*/
/*VERRIFY EMAIL ADDRESS AND PASSWORD AND MATCH IN SYSTEM*/
function validateLogin($emailaddress='', $password=''){
/*INITIALIZES VARIABLES*/
$email_key = '[email protected]';
$password_key = '1234';
$auth_match = 0;
/* CHECK FOR MATCH */
if($emailaddress == $email_key && $password == $password_key){
$auth_match = 1;
}
return $auth_match;
}
/*CLEAN FORM DATA*/
function sanitize($form_var) {
$clean_data = strtolower(trim($form_var));
return $clean_data;
}
/*PAGE VARIABLES*/
$auth_status = 0;
/*DETERMINE FORM HAS BEEN SUBMITTED*/
if(array_key_exists('submit', $_POST)) {
/*SANITIZE FORM DATA*/
$emailaddress = sanitize($_POST['emailaddress']);
$password = sanitize($_POST['password']);
/*VALIDATE FORM DATA*/
$auth_status = validateLogin($emailaddress, $password);
}
?>
</div><div class="container" id="shadow">
<div>
<?php
include(ABSOLUTE_PATH . 'header.inc.php');
if($auth_status == 1){
/*AUTHENTICATION SUCCESS*/
echo '<h4>Welcome Back, Betty!</4>' . "\n\n";
echo '<ul>' . "\n";
echo "\t" . '<li><a href="' . APP_ROOT . 'onlinebanking" title="Online Banking">Online Banking</a></li>' . "\n\n";
echo '</ul>';
} elseif($auth_status == 0){
/*AUTHENTICATION FAILED*/
echo '<h4 class="error">Authentication Error!</h4>' . "\n\n";
echo '<p>Incorrect e-mail address and/or password submitted. Please try again.</p>';
}
?>
<div>
</div><!--End of main content-->
<?php
include(ABSOLUTE_PATH . 'footer.inc.php');
?>
这是我的登录表单
<div id="login_form">
<form id="login" method="post" action="processlogin.php">
<label for="emailaddress"> E-mail Address: </label>
<input type="text" id="emailaddress" name"emailaddress" maxlength="100" tabindex="1" />
<label for="password"> Password: </label>
<input type="password" id="password" name="password" maxlength="13" tabindex="2" />
<input type="submit" id="login_submit" name="submit" value="login"/>
</form>
</div>
这是我的主索引页:
<?php require_once('websiteconfig.inc.php'); ?>
<div> <h1 class="h1" align="center"> 1%'er Savings <bold> & </bold> Loan </h1> </h1> </hr> </div><!--End of Body--> <?php require_once('footer.inc.php'); ?> </div><!--end of header-->
这是我的头
首页登录页/ _assets /样式/风格.css“/>
/_assets/images/bkrnd_top.png “> /_assets/images/bkgrnd_tl.png” WIDTH = “205” 高度= “61”> /_assets/images/logo.png “WIDTH = ”160“ 高度= ”61“>
/_assets/images/background_headerarea.png”>
首页 | TBA | TBA | TBA | TBA | TBA
哇....我一直打算在我的代码小时....谢谢! – 2012-02-11 20:21:37
重要提示 - 如果某些内容不能按预期工作,请使用'print_r($ _ POST)将您发布的内容转储到屏幕上;' - 然后您就可以准确了解从表单中收到的数据 – MrJ 2012-02-11 21:03:50