le 15/07/2007 à 11:42
jackbocar
J'ai une erreur que je ne vois pas !
Merci de votre aide
Jack Bocar
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Verification identification</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="index,follow" />
<meta name="category" content="histoire" />
<meta name="revisit-after" content="1 days" />
<meta name="author" lang="fr" content="Jack Bocar" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" media="screen" href="./css/main.css" />
</head>
<body>
<?php echo $message ?>
<br /><br />
<form action="verif.php" method="post">
Login : <input type="text" name="login" value="<?php if (isset($_POST['login'])) echo stripslashes(htmlentities(trim($_POST['login']))); ?>"><br />
Mot de passe : <input type="password" name="pass" value="<?php if (isset($_POST['pass'])) echo stripslashes(htmlentities(trim($_POST['pass']))); ?>"><br />
<input type="submit" name="connexion" value="Connexion">
</form>
</body>
</html>
Merci de votre aide
Jack Bocar
<?php
$dbhote = 'localhost';
$dbuser = 'jackbocar';
$dbpass = 'XXXXXXXXXX';
$dbbase = 'Base_test';
$dsn = "mysql:dbname=$dbbase;host=$dbhote";
$dbh = new PDO($dsn, $dbuser, $dbpass);
?>
<?php
if (isset($_POST['connexion']) && $_POST['connexion'] == 'Connexion') {
if ((isset($_POST['login']) && !empty($_POST['login'])) && (isset($_POST['pass']) && !empty($_POST['pass']))) {
$sql = ('SELECT count(*) FROM user as nbres WHERE login="'.mysql_escape_string($_POST['login']).'" AND pass_md5="'.md5(mysql_escape_string($_POST['pass'])).'"');
$result = $dbh->query($sql);
$data = $result->fetch();
$dbh = null;
if ($data['nbres'] == 1) {
session_start();
$_SESSION['login'] = $_POST['login'];
header('Location: membre.php');
exit();
}
elseif ($nbres == 0) {
$message = 'Compte invalide.';
}
else {
$message = 'La base de donnée est down.';
}
}
else {
$message = 'Un des champs requis est vide.';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Verification identification</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="index,follow" />
<meta name="category" content="histoire" />
<meta name="revisit-after" content="1 days" />
<meta name="author" lang="fr" content="Jack Bocar" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" media="screen" href="./css/main.css" />
</head>
<body>
<?php echo $message ?>
<br /><br />
<form action="verif.php" method="post">
Login : <input type="text" name="login" value="<?php if (isset($_POST['login'])) echo stripslashes(htmlentities(trim($_POST['login']))); ?>"><br />
Mot de passe : <input type="password" name="pass" value="<?php if (isset($_POST['pass'])) echo stripslashes(htmlentities(trim($_POST['pass']))); ?>"><br />
<input type="submit" name="connexion" value="Connexion">
</form>
</body>
</html>