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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| <?php
session_start();
function search_result($pseudo){
$mdp_querry = mysql_query('SELECT mdp FROM membre WHERE pseudo="'.$pseudo.'"');
if($echo_mdp = mysql_num_rows($mdp_querry)){
return $echo_mdp;
}
return $echo_mdp;
}
function verification($pseudo, $motdepasse, $echo_mdp){
if(empty($pseudo) || empty($motdepasse)){
return 1;
}
$mdp_querry = mysql_query('SELECT mdp FROM membre WHERE pseudo="'.$pseudo.'"');
$data = mysql_fetch_assoc($mdp_querry);
if($echo_mdp == 0){
return 2;
}
elseif($data['mdp'] != $motdepasse){
return 3;
}
else{
$erreur = null;
return $erreur;
}
}
if(isset($_POST['auth_pseudo']) && isset($_POST['auth_mdp'])){
require 'config.php';
$co_serv = mysql_connect(DB_HOST,DB_LOGIN,DB_PASS);
$co_bdd = mysql_select_db(DB_BDD);
if(!$co_serv || !$co_bdd){
return 4;
}
$pseudo = mysql_real_escape_string($_POST['auth_pseudo']);
$motdepasse = sha1($_POST['auth_mdp']);
$echo_mdp = search_result($pseudo);
$erreur = verification($pseudo, $motdepasse, $echo_mdp);
if(empty($erreur)){
if(isset($_POST['checkbox'])){
setcookie('pseudo',$pseudo,(time()+60*60*24*30));
setcookie('motdepasse',$motdepasse,(time()+60*60*24*30));
header('Location: http://127.0.0.1/monprojet/index.php');
}
else{
$_SESSION['pseudo'] = $pseudo;
$_SESSION['motdepasse'] = $motdepasse;
header('Location: index.php');
}
}
else{
$_SESSION['erreur'] = $erreur;
header('Location: erreur_auth.php?erreur='.$erreur.'');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index</title>
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="design.css" />
</head>
<body>
<div id="corp"> <!-- Corp de la page -->
<div id="banniere"> <!-- Bannière de la page -->
</div>
<div id="menu"> <!-- Menu horizontal -->
<ul id="onglets"> <!-- Menu horizontal de la page -->
<li class="arrondi"><a href="index.php">Accueil</a></li>
<li><a href="astuces.php">Exposez !</a></li>
<li><a href="forum/index.php">Forum</a></li>
</ul>
</div>
<?php
if((!isset($_SESSION['pseudo']) && !isset($_SESSION['motdepasse']))){
?>
<div id="connexion"> <!-- Espace connection de la page -->
<span class="titreconnexion">C'est qui ?</span>
<form method="post">
<label for="auth_pseudo" style="font:14px calibri" maxlength="16" >Pseudo : <br/></label>
<input type="text" name="auth_pseudo" /><br /><br />
<label for="auth_mdp" style="font:14px calibri">Mot de passe : <br /></label>
<input type="password" name="auth_mdp" /><br /><br />
<input type="checkbox" name="checkbox" />
<label for="checkbox" style="font:12px calibri">Se souvenir de moi</label><br /><br />
<a href="id_oublie.php" style="font:11px calibri; text-decoration:none; color:#000;" >Identifiants oubliés ?</a><br /><br/>
<input type="submit" name="submit" Value="Connexion" /><br /><br/>
<a href="inscription.php" style="font:14px calibri; text-decoration:none; color:#FF9600;"><u>Pas encore inscrit ?</u></a>
</form>
</div>
</div>
</body>
</html>
<?php
}
else{
?>
<a href="deconnexion.php">Déconnexion.</a>
<?php
echo $_COOKIE['pseudo'];
}
?> |
Partager