我正在尝试创建一个带有PDO和会话的登录/注册系统,用户可以创建他的帐户,他可以访问欢迎页面,但是当注销并尝试使用工作用户名和密码登录时,它会将我发送到一个空白的php页面,我在互联网上查看和空白的php页面意味着语法错误,我找不到任何。顺便说一句,我尝试用任何密码输入任何用户名,它仍然将我发送到一个空白的php页面,这是我的代码:Config.php
class config {
public static function connect()
{
$host = "localhost";
$username = "root";
$password = "";
$dbname = "logintest";
try{
$bdd = new PDO("mysql:host=$host;dbname=$dbname",$username,$password);
$bdd->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
}catch(PDOException $e)
{
echo "Connection échoué" . $e->getMessage();
}
return $bdd;
}
}
?>
我的过程.php(这就是我认为问题的根源:
session_start();
include_once("config.php");
if(isset($_POST['register']))
{
$bdd = config::connect();
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
if(insertDetails($bdd,$username,$email,$password))
{
$_SESSION['username'] = $username;
header("Location: profile.php");
}
}
if(isset($_POST['login']))
{
$bdd = config::connect();
$username = $_POST['username'];
$password = $_POST['password'];
if(checkLogin($bdd,$username,$password))
{
$_SESSION['username'] = $username;
header("Location: profile.php");
}
else{
echo "Le mot de passe ou le nom d'utilisateur sont incorrect";
}
}
function insertDetails($bdd,$username,$email,$password)
{
$query = $bdd->prepare("
INSERT INTO users (username,email,password)
VALUES(:username,:email,:password)
");
$query->bindParam(":username",$username);
$query->bindParam(":email",$email);
$query->bindParam(":password",$password);
return $query->execute();
}
或者这是我正在做的项目:https://github.com/AmrouHab/LoginRegister/tree/master/neptunetest
我会得到任何帮助 谢谢(顺便说一句,对不起我的英语不好的法语)
BIG阳