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
require('src/connection.php');
if (isset($_POST['pseudo']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password2'])) {
$pseudo = $_POST['pseudo'];
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
// TEST MOT DE PASSE IDENTIQUE INCRIPTION
if ($password != $password2) {
header('location: ../?error=1&pass=1'); // redirige l'utilisateur avec un message derreur dans l'url
}
// TEST POUR SAVOIR SI LE MAIL EST DEJA PRESENT DANS LA BASE DE DONNEE
$req = $db->prepare('SELECT count (*) as numberEmail FROM users WHERE email = ?');// LA VALEUR COUNT (*) COMPTE LE NOMBRE DE LIGNE
$req->execute(array($email)); // on execute l'email inserer
while ($email_verification = $req->fetch()){
if ($email_verification['numberEmail'] !=0) {
header ('location: ../?error=1&email=1');
}
}
//HASS SECURITE
$password2 = sha1($email).time();
$password2 = sha1($password2).time().time();
//CRYPTAGE MOT DE PASSE
$password = "aq1".sha1($password."12857")."34";
// ENVOI DE LA REQUETE
$req = $db->prepare('INSERT INTO users(pseudo,email,password,password2) VALUES(?,?,?,?)');
$req->execute(array($pseudo,$email,$password,$password2));
header('location: ../?success=1');
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<h1>Inscription</h1>
<p>Bienvenue sur mon site pour en voir plus inscrivez-vous. Sinon <a href="connection.php">Connectez-vous</a></p>
<?php
if(isset($_GET['error'])) { // SI IL EXISTE UNE ERREURE
if(isset($_GET['pass'])){ // SI CETTE ERREURE EST LIEE AU MOT DE PASSE
echo '<p id="error">La confirmation du mot de passe ne correspond pas au mot de passe taper</p></br>';
}
else if (isset($_GET['email'])){ // S'IL EXISTE UNE ERREURE SUR LE MAIL
echo '<p id="error"> Cet email est deja utiliser </p>';
}
}
Else if (isset($_GET['success'])){
echo '<p id="success">Votre compte a ete creer avec succees</p>';
}
?>
<legend> Coordonnées d'inscription </legend><br>
<form method="POST" action="index.php">
<fieldset>
<table>
<tr>
<td><label>Pseudo :</label></td>
<td><input type="text" name="pseudo" placeholder="Ex: Herve" required /></td>
</tr>
<tr>
<td><label>Email :</label></td>
<td><input type="email" name="email" placeholder="Ex: Herve.dupont@gmail.com" required /></td>
</tr>
<tr>
<td><label>Mot de passe :</label></td>
<td><input type="password" name="password" placeholder="Ex: *******" required /></td>
</tr>
<tr>
<td><label>Confirmer le mot de passe :</label></td>
<td><input type="password" name="password2" placeholder="Ex: *******" required /></td>
</tr>
</table><br>
<button type="submit">Inscription</button>
</fieldset>
</form>
</body>
<footer>
</footer>
</html> |
Partager