我正在尝试创建一个带有PDO和会话的登录/注册系统,用户可以创建他的帐户,他可以访问欢迎页面,但是当注销并尝试使用工作用户名和密码登录时,它会将我发送到一个空白的php页面,我在互联网上查看和空白的php页面意味着语法错误,我找不到任何。顺便说一句,我尝试用任何密码输入任何用户名,它仍然将我发送到一个空白的php页面,这是我的代码:Config.phpclass 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我会得到任何帮助 谢谢(顺便说一句,对不起我的英语不好的法语)
1 回答
BIG阳
TA贡献1859条经验 获得超6个赞
Well , i found the solution I forgot to put an uppercase "L" in process.php
if(isset($_POST['login']))
I've corrected it to
if(isset($_POST['Login']))
and now it's working. Thanks for your attention.
- 1 回答
- 0 关注
- 70 浏览
添加回答
举报
0/150
提交
取消