저는 주로 내 오류가 변수가 테이블에서 가져 오지 않았 음을 확인했습니다. 그러나 사용자 이름과 암호를 묻는 동시에 해당 데이터를 요구하는 오류를 볼 수 없습니다. 표는 [사용자 이름], [비밀번호], [회사]로 구성됩니다. 목표는 사용자 이름과 비밀번호가 확인 된 후 회사의 이름을 기반으로 사용자를 유도하도록하는 것입니다. 마지막에 에코가 계속 나타납니다.변수를 사용하여 트래픽을 유도하십시오.
$sql = "SELECT 'password' and 'company' from users where 'username' = '$username';";
이 식별자 주위
$sql = "SELECT `password`, `company` from `users` where `username` = '$username'";
사용 역 따옴표가 아닌 따옴표해야한다 :
여기
function RegisterUser($usename, $password, $company)
{
// hash the pwd
$hpwd = hash('sha256',$password);
$q ='insert into users values(username, password, company) values(?,?,?)';
$stmt = PDO::prepare($q);
$stmt->exectue(array($username, $hpwd, $company));
}
// validate user and return the company if successfull
function ValidateUser($username, $password, &$company)
{
$hpwd = hash('sha256',$password);
$q ='select company from users where username=? AND password=?';
$stmt = PDO::prepare($q);
$stmt->exectue(array($username, $hpwd));
if(($company = $stmt->fetch(PDO::FETCH_COLUMN)) === false)
{
$company = header('Location: login.php');
}
elseif($company == "monkeynones"){
header('Location: admin1.php');
}
대부분 확실합니까? '$ row'에 내용을 덤프하고 비어 있는지 확인하십시오. 나는 그것을 훨씬 더 분명하게 만들 것이다. 또한, 내가 아는 한'password','company'와'username'을 따옴표 안에 넣지 않아도됩니다. 나는 당신이'\''을 사용하는 것을 의미한다고 생각하는데, 틀린 것 같지만. – OptimusCrime
[mysql 확장 기능은 더 이상 사용되지 않습니다.] (http://www.php.net/manual/en/function.mysql-connect.php) –
열 이름을 나타내며 $ row에 print_r을 추가했습니다. –