-
Notifications
You must be signed in to change notification settings - Fork 0
/
valider_compte.php
63 lines (63 loc) · 1.93 KB
/
valider_compte.php
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
<?php require_once("config_mysql.php");
require_once("fonctions.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Checker</title>
<script type="text/javascript">
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Inscription</h1>
<?php
if(isset($_POST['envoi']) && $_POST['envoi'] == 1)
{
$uid = intval($_POST['uid']);
$code = htmlspecialchars($_POST['code']);
$mdp = htmlspecialchars($_POST['mdp']);
$remdp = htmlspecialchars($_POST['mdp_re']);
if($mdp != $remdp)
{
echo "<p>Les mots de passes ne correspondent pas</p>";
exit();
}
$requete = mysql_query("SELECT code FROM utilisateurs WHERE uid = ".$uid." AND valide = 0");
if($donnees = mysql_fetch_array($requete))
{
if($donnees['code'] != $code)
{
echo "<p>Les codes ne correspondent pas</p>";
exit();
}
$hashage = hash('sha512', $mdp.$code);
mysql_query('UPDATE utilisateurs SET valide = 1, mdp = "'.$hashage.'" WHERE uid = '.$uid);
echo "<p>Merci, le compte est maintenant validé, vous pouvez dorénavant vous connecter<br /><a href='connexion.php'>Se connecter</a></p>";
} else
{
echo "<p>L'uid n'est pas inscrit ou le compte est déjà validé</p>";
exit();
}
} elseif(isset($_GET['u']) && isset($_GET['code']))
{ ?>
<form action="valider_compte.php" method="post">
<label name="uid">UID : <br />
<input name="uid" value="<?php echo intval($_GET['u']); ?>" /></label><br />
<label name="code">Code : <br />
<input name="code" value="<?php echo $_GET['code']; ?>" /></label><br />
<label name="mdp">Mot de passe : <br />
<input name="mdp" type="password" /></label><br />
<label name="mdp_re">Encore une fois : <br />
<input name="mdp_re" type="password" /></label><br />
<input name="envoi" value="1" type="hidden" />
<input type="submit" value="Valider" />
</form>
<?php } else
{
echo "<p>Erreur</p>";
} ?>
</body>
</html>
<?php mysql_close(); ?>