I just finished coding my login page, and I have these problems showing up, do you have any idea?
[Tue Mar 9 22:55:11 2021] PHP Notice: Undefined variable: rounds in /home/swan/Epitech/Tweet_academie/html/connexion.php on line 28 [Tue Mar 9 22:55:11 2021] PHP Notice: Undefined variable: sfopdgijtsposrigjsotij in /home/swan/Epitech/Tweet_academie/html/connexion.php on line 28
[Tue Mar 9 22:55:11 2021] PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='swan.marin@gmail.com' AND password='$65I6KH/.1F1w'' at line 1 in /home/swan/Epitech/Tweet_academie/db/connexiondb.php on line 37 [Tue Mar 9 22:55:11 2021] PHP Notice: Trying to access array offset on value of type bool in /home/swan/Epitech/Tweet_academie/html/connexion.php on line 32
<html>
<?php
session_start();
include('../db/connexiondb.php'); // Fichier PHP contenant la connexion à votre BDD
// S'il y a une session alors on ne retourne plus sur cette page
if (isset($_SESSION['id']))
{
header('Location: index.php');
exit;
}
// Si la variable "$_Post" contient des informations alors on les traitres
if(!empty($_POST))
{
extract($_POST);
$valid = true;
if (isset($_POST['connexion']))
{
$email = htmlentities(strtolower(trim($email)));
$mdp = trim($mdp);
// On fait une requête pour savoir si le couple mail / mot de passe existe bien
$req = $DB->query("SELECT * FROM users WHERE email=? AND password=?",
array($email, crypt($mdp, "$6$rounds=5000$sfopdgijtsposrigjsotij$")));
$req = $req->fetch();
// Si on a pas de résultat alors c'est qu'il n'y a pas d'utilisateur correspondant au couple mail / mot de passe
if ($req['id'] == "")
{
$valid = false;
$er_email = "Le mail ou le mot de passe est incorrecte";
}
// S'il y a un résultat alors on va charger la SESSION de l'utilisateur en utilisateur les variables $_SESSION
if ($valid)
{
$_SESSION['id'] = $req['id'];
$_SESSION['name'] = $req['name'];
$_SESSION['email'] = $req['email'];
header('Location: index.php');
exit;
}
}
}
?>