사용자 이름과 암호가있는 간단한 로그인 페이지 (index.php)가 있습니다. 모든 데이터베이스 관련 기능을 가진 db_connect.php라는 파일을 만들었습니다.PHP MySQL 로깅 문제
class Database{
private $connection;
private $db;
function __construct()
{
$this->connection = mysql_connect('localhost','root','') or die("cannot connect");
$this->db = mysql_select_db('logistics',$this->connection);
}
function verify_login($uid,$password)
{
$verify_login = "select user_id from log_users where user_login = '$uid' and user_password = '$password'";
$status = mysql_query($verify_login,$this->connection);
while($result = mysql_fetch_assoc($status)){
if($result['user_id'] == '1')
{
return true;
}
else{
return false;
}
}
}
이제 verify_login ($ username, $ password) 함수를 호출하는 데 사용되는 클래스 데이터베이스의 개체를 만들었습니다. 여기서 문제는 로그인의 상태와 상관없이 출력이 빈 페이지라는 것입니다. 변수 $ status를 출력하면 리소스 ID를 반환합니다. 하지만 아무것도 반환되지 않습니다. 놀라운
? 당신의 함수가 적합 할 때 true/false를 리턴하는지 알 수 있습니까? –