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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
<?php
if (isset($_POST['registration']))
{
if(empty($_POST['username']) || !preg_match('/[a-z0-9]+/', $_POST['username']))
{
$avert = 'Username must be lowercase, letters or numbers !';
}
elseif(empty($_POST['password']) || $_POST['password'] != $_POST['passwordRetype'])
{
$avert = 'Invalid or unlike password !';
}
elseif(empty($_POST['pincode']) || $_POST['pincode'] != $_POST['pincodeRetype'])
{
$avert = 'Invalid or unlike PIN code !';
}
else
{
$username = $_POST['username'];
$password = $_POST['$password'];
$pincode = $_POST['pincode'];
$db= new PDO('mysql:host=localhost;dbname=dbtest;charset=utf8', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$req = $db->prepare('SELECT count(*) as numberUsers FROM users WHERE username = ?');
$req->execute(array($username));
while($username_verification = $req->fetch())
{
if ($username_verification['numberUsers'] != 0)
{
$avert = 'Username already exist !';
}
}
$secret = sha1($pincode).time();
$secret = sha1($secret).time();
$password = "0512".sha1($password."379")."9356842";
$req = $db->prepare("INSERT INTO users (username, password, pincode, secret) VALUES(?, ?, ?, ?)");
echo 'Ok'; // Cet echo cesse de fonctionner à partir d'ici, plus haut il est toujours affiché.
$req->execute(array($username, $password, $pincode, $secret));
header('location: ../?success=1');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../login.css">
<meta charset="utf-8" />
<title>Espace Membre</title>
</head>
<body>
<header>
<?php include("../banner.php"); ?>
</header>
<style>
body { background-image: url('../wllppr.jpg'); }
</style>
<?php include("../menu.php"); ?>
<br>
<br>
<div class="connectDivCenter">
<h1 class="connectTitle">Member Registration</h1>
<?php if (isset($avert)) echo $avert;?>
<form method="post" action="register.php">
<p class="connectLabel">
<label for="username">Choose your username</label>
<br>
<input class="connectInput" type="text" name="username" placeholder="username in lowercase only" required/>
</p>
<p class="connectLabel">
<label for="password">Type a strong password</label>
<br>
<input class="connectInput" type="password" name="password" placeholder="STRONG PASSWORD" required/>
</p>
<p class="connectLabel">
<label for="passwordRetype">Retype your password</label>
<br>
<input class="connectInput" type="password" name="passwordRetype" placeholder="STRONG PASSWORD AGAIN" required/>
</p>
<p class="connectLabel">
<label for="pincode">Type a PIN code</label>
<br>
<input class="connectInput" type="tel" name="pincode" min="123456" placeholder="Ex : 93568742" required/>
</p>
<p class="connectLabel">
<label for="pincodeRetype">Retype PIN code</label>
<br>
<input class="connectInput" type="tel" name="pincodeRetype" min="123456" placeholder="Keep PIN code safe" maxlength="10"/ required>
</p>
<p>
<button class="connectSubmit" type="submit" name="registration"/>Submit</button>
</p>
<p class="connectInfo">
Already registered ?
<br>
<br>
<a href="login.php"><input class="connectRegisterButton" type="button" value="Log In"/></a>
<br>
</p>
</form>
</div>
</body>
<footer>
<?php include("../footer.php"); ?>
</footer>
</html> |
Partager