Salut tout le monde, j'ai une erreur 500 que je ne comprend pas... L'erreur doit probablement être au niveau du deuxième bloc car avant que je le modifie cela marchait. Je n'ai peut être pas bien compris comment me servir de PDO prepare et execute mais même en regardant la doc je ne vois pas l'erreur. une idée?
Modifié par NiceRage (07 May 2018 - 12:10)
<?php
use Symfony\Component\Yaml\Yaml;
require __DIR__.'/../vendor/autoload.php';
$connectionParams = Yaml::parseFile(__DIR__.'/../config/db.yml');
$config = new \Doctrine\DBAL\Configuration();
$bdd = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
$name = ($_POST['name']);
$password = ($_POST['password']);
$sql = "SELECT name_partner, password_partner, id_partner FROM partner;";
$sth = $bdd->prepare($sql);
$sth->execute();
$partner = $sth->fetchAll();
$sql = "SELECT name_gmc, password_gmc, id_gmc FROM gmc;";
$sth = $bdd->prepare($sql);
$sth->execute();
$gmc = $sth->fetchAll();
$sql = "SELECT name_admin, password_admin, id_admin FROM administrator;";
$sth = $bdd->prepare($sql);
$sth->execute();
$admin = $sth->fetchAll();
while ($test = $partner -> fetch()) {
if (($name == $test['name_partner']) && (password_verify($password, $test['password_partner'])) ) {
session_start();
$_SESSION['userid']=$test['id_partner'];
$_SESSION['type']="partner";
break;
}
}
while ($test = $gmc -> fetch()) {
if (($name == $test['name_gmc']) && (password_verify($password, $test['password_gmc'])) ) {
session_start();
$_SESSION['userid']=$test['id_gmc'];
echo($_SESSION['userid']);
$_SESSION['type']="gmc";
break;
}
}
while ($test = $admin -> fetch()) {
if (($name == $test['name_admin']) && (password_verify($password, $test['password_admin'])) ) {
session_start();
$_SESSION['userid']=$test['id_admin'];
$_SESSION['type']="admin";
break;
}
}
if (isset($_SESSION['userid'])) {
header('Location: /../../public/language.php');
}
else {
echo "bad password";
}
Modifié par NiceRage (07 May 2018 - 12:10)