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
|
$dsn = array(
'phptype' => 'mysql',
'username' => 'someuser',
'password' => 'apasswd',
'hostspec' => 'localhost',
'database' => 'thedb',
);
$options = array(
'debug' => 2,
'portability' => MDB2_PORTABILITY_ALL,
);
$db = & MDB2::connect($dsn, $options);
$db = & MDB2::Connect($dsn, array());
if(PEAR::isError($db))
{
die($db->getMessage());
}
// connexion a la table utilisateur pour récuperer les identifiants et utilisateurs
$res = $db->query("SELECT id FROM utilisateurs WHERE nom=? AND password=MD5(?)", array( $_POST['identification'], $_POST['password']));
// contrôle si il y a quelque chose dans le tableau (identiffiant et password)
$row = array(null);
if($res != null)
$res->fetchInto($row);
if($row[0] != null)
{
session_start();
$_SESSION['utilisateur'] = $row[0];
header( "Location: bienvenue.php" );
}
else
{
header( "Location: index.php?inc=1" );
} |
Partager