-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinscription_bdd.php
59 lines (42 loc) · 959 Bytes
/
inscription_bdd.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
<?php
include_once("./includes/fonctions.php");
if(isSet($_POST["login"]))
{
$login = trim($_POST["login"]);
if(strlen($login) == 0 || strlen($login) > 32)
{
fail(1);
}
$p = getPlayer($login);
if($p)fail(2);
if(isSet($_POST["mdp"]))
{
$mdp = $_POST["mdp"];
if(strlen($mdp) == 0)
{
fail(3);
}
$req = $bdd -> prepare("INSERT INTO joueurs (login,password,date,score,victoires,egalites,defaites) VALUES (:login,:password,NOW(),0,0,0,0)");
$req -> bindParam(":login",$log);
$req -> bindParam(":password",$pass);
$log = $login;
$pass = $mdp;
$score = 0;
$req -> execute();
$row = getPlayer($login);
$_SESSION["login"] = $row["login"];
$_SESSION["score"] = $row["score"];
$_SESSION["date"] = $row["date"];
header("Location: defier.php");
}
}
else
{
fail(0);
}
function fail($err)
{
header("Location: inscription.php?err=$err");
exit();
}
?>