로그온하려고하면 인증되지 않습니다. 오류가 반환되지 않습니다. 사용자 이름과 암호가 코드에 있습니다 (사용자 이름과 암호는 데이터베이스에 보관되지 않은 PHP 코드 안에 있습니다).PHP의 기본 질문
elseif($auth_status == 0); {
echo '<h4>Authentication error please try again! </h4>' . "\n\n";
형식이 잘못되는 것을 (그리고 아마 당신이 원하지 않는 것을)
<?php
/* This is the location of the file and will be used as the baseline for all
of my files writing of code within php. */
/*require files for application */
require_once('websiteconfig.inc.php');
define('ABSOLUTE_PATH ', '../public_html/cit0215/assignment2/');
/*This will define my index.php file */
define('URL_ROOT ', 'https://wiki.cit.iupui.edu/~mjcrawle/cit0215/assignment2/index.php/');
/*functions that validate logins */
function validateLogin($emailaddress='', $password='') {
/*Initialized the Variable from the original from the form */
$email_key = '[email protected]';
$password_key = '1234';
$auth_match = 0;
/*This is the first If statement the test username and password*/
if ($emailaddress == $email_key && $password == $password_key) {
$auth_match=1;
}
/*this is what ensure the username and password are correct*/
return $auth_match;
}
function sanitize($form_var){
$clean_data = strtolower(trim($form_var));
return $clean_data;
}
/*Authticate the status of logins*/
$auth_status =0;
/*Determine if the form data was submitted*/
if (array_key_exists('submit', $_POST)){
/*this removes left over data*/
$emailaddress = sanitize($_POST['emailaddress']);
$password = sanitize($_POST['password']);
/*verify form data*/
$auth_status = validateLogin($emailaddress, $password);
}
include('header/header.inc.php');{
if($auth_status == 1){
/*successful logon*/
echo '<h3>Welcome Back, Betty!... Your not ugly after all</h3>' . "\n\n";
echo '<ul>' . "\n";
echo "\t" . '<li><a href"' . URL_ROOT . 'onlinebanking" title="Online
Banking">On Line Banking</a> </li>' . "\n\n";
echo '</u>';
}
elseif($auth_status == 0); {
/*authentication has failed*/
echo '<h4>Authentication error please try again! </h4>' . "\n\n";
echo '<p> Please make sure that the "Numbers lock" or "Caps Lock" is not
on and re-type your password.</p>';
}
include('footer_nav/footer.inc.php');
}
?>
너무 길어 들여 쓰기가 너무 많습니다. 코드를 올바르게 포맷하십시오. 방금 질문에 대답하기 위해 엄청난 양의 공백을 스크롤하지 않으려 고합니다. – ThiefMaster
어떻게 로그온 하시겠습니까? 이 코드에 제출하는 양식은 어디에 있습니까? 제출이라는 요소가 있습니까? 이 코드가 실행되면 $ _POST에 무엇이 있습니까? –
죄송합니다. 먼저 기본 디버깅을 요청합니다. 테스트 출력을 한 라인 씩 차례대로 작성하여 정확한 문제를 찾아내는 방법으로 사용하면 안됩니다. * 그 질문은 가치가 있습니다. –