1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <?php
session_start();
include 'inc/define.inc.php';
include 'inc/fct.inc.php';
if (isset($_POST["txtlogin"]) && isset($_POST["pwdpassword"]))
{
// Ouvre une connexion au serveur MySQL
$connection = mysql_connect(NOM_SERVEUR, NOM_ROOT, NOM_PASSWORD);
if (!$connection) {
fin_perso('Problème de connexion au serveur : '. ' ---' . NOM_SERVEUR. '- - -' . NOM_ROOT. '- - -' . NOM_PASSWORD. '- - - ' . mysql_error(), 'erreur_bd_');
}
// Sélectionne une base de données MySQL
if (!mysql_select_db(NOM_BD))
{
fin_perso('Problème de connexion à la base de données : ' . mysql_error(), 'erreur_bd');
}
$sql = "SELECT U_id, U_Login, U_Password, U_Nom, U_Prenom FROM t_usager WHERE U_Login = '" . addslashes($_POST["txtlogin"]) . "' AND U_Password = '" . addslashes($_POST["pwdpassword"]) . "' ;";
$resultat = mysql_query($sql);
if (!$resultat)
{
fin_perso('Problème de requête' .$sql. '--'. mysql_error(), 'erreur_bd');
}
if ($ligne = mysql_fetch_array($resultat))
{
$_SESSION['user_in'] = $ligne['U_Prenom'] . " " . $ligne['U_Nom'];
header("Location: admin.php");
}
else
{
log_erreur('Erreur de connexion : ' . $_POST["txtlogin"] . ' ' .$_POST["pwdpassword"]);
header("Location: index.php?erreur=erreurlogin");
}
}
else
header("Location: index.php?erreur=accesinterdit");
?> |
Partager