登录不起作用,但不会给出任何错误

时间:2018-05-29 18:41:59

标签: php

我无法登录我的网络应用程序,我正在插入正确的组合,但它只显示“抱歉,这些凭据不匹配”消息。

<?php

session_start();

if( isset($_SESSION['user_id']) ){
	header("Location: /");
}

require 'database.php';

if(!empty($_POST['username']) && !empty($_POST['password'])):
	
	$records = $conn->prepare('SELECT id, policajt_id, username, password FROM users WHERE username = :username');
	$records->bindParam(':username', $_POST['username']);
	$records->execute();
	$results = $records->fetch(PDO::FETCH_ASSOC);

	$message = '';

	if(count($results) > 0 && password_verify($_POST['password'], $results['password']) ){

		$_SESSION['user_id'] = $results['id'];
		header("Location: /");

	} else {
		$message = 'Sorry, those credentials do not match';
	}

endif;

?>

非常感谢任何帮助。提前谢谢!

0 个答案:

没有答案