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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
| <?php
$bdd = new PDO('mysql:host=127.0.0.1; dbname=my_covergratuit', 'covergratuit', '');
if(isset($_POST['forminscription']))
{
$pseudo = htmlspecialchars($_POST['pseudo']);
$mail = htmlspecialchars($_POST['mail']);
$mailconfirm = htmlspecialchars($_POST['mailconfirm']);
$mdp = sha1($_POST['mdp']);
$mdpconfirm = sha1($_POST['mdpconfirm']);
$deckstart = ($_POST['deckstart']);
if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mailconfirm']) AND !empty($_POST['mdp']) AND !empty($_POST['mdpconfirm']) AND !empty($_POST['deckstart']) )
{
$pseudolenght = strlen($pseudo);
if($pseudolenght <= 255)
{
$reqpseudo = $bdd->prepare("SELECT * FROM membres WHERE pseudo = ?");
$reqpseudo ->execute(array($pseudo));
$pseudoexist = $reqpseudo->rowCount();
if($pseudoexist == 0)
{
if($mail == $mailconfirm)
{
if(filter_var($mail, FILTER_VALIDATE_EMAIL))
{
$reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
$reqmail ->execute(array($mail));
$mailexist = $reqmail->rowCount();
if($mailexist == 0)
{
if($mdp == $mdpconfirm)
{
$insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, mdp, deck) VALUES (?, ?, ?, ?)");
$insertmbr->execute(array($pseudo, $mail, $mdp, $deckstart));
$erreur = "Votre compte à bien était créé.";
}
else
{
$erreur = "Vos mots de passe ne correspondent pas.";
}
}
else
{
$erreur = "Adresse mail déjà inscrite.";
}
}
else
{
$erreur = "Pseudo déjà inscrit";
}
}
else
{
$erreur = "Votre adresse mail n'est pas valide.";
}
}
else
{
$erreur = "Vos adresses mail ne correspondent pas.";
}
}
else
{
$erreur = "Votre pseudo ne doit pas dépasser 255 caractères.";
}
}
else
{
$erreur = "Tous les champs doivent êtres complétés !";
}
}
?>
<html>
<head>
<title>HVSP</title>
<meta charset="utf-8">
</head>
<body>
<div align="center">
<h2>Inscription</h2>
<br /><br />
<form method="POST" action="
">
<table>
<tr>
<td align="right">
<label for="pseudo">Pseudo :</label>
</td>
<td>
<input type="text" placeholder="Pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) {echo $pseudo;} ?>" />
</td>
</tr>
<tr>
<td align="right">
<label for="mail">Mail :</label>
</td>
<td>
<input type="email" placeholder="Mail" id="mail" name="mail" value="<?php if(isset($mail)) {echo $mail;} ?>" />
</td>
</tr>
<tr>
<td align="right">
<label for="mailconfirm">Confirmation du Mail :</label>
</td>
<td>
<input type="email" placeholder="Confirmation Mail" id="mailconfirm" name="mailconfirm" value="<?php if(isset($pseudo)) {echo $pseudo;} ?>"/>
</td>
</tr>
<tr>
<td align="right">
<label for="mdp">Mot de Passe :</label>
</td>
<td>
<input type="password" placeholder="Mot de Passe" id="mdp" name="mdp" />
</td>
</tr>
<tr>
<td align="right">
<label for="mdpconfirm">Confirmation Mot de Passe :</label>
</td>
<td>
<input type="password" placeholder="Confirmation Mot de Passe" id="mdpconfirm" name="mdpconfirm" />
</td>
</tr>
<tr>
<td></td>
<td align="center">
<label for="feu">Feu :</label>
<input type="radio" id="deckstart" name="deckstart" value="feu" />
<label for="eau">Eau :</label>
<input type="radio" id="deckstart" name="deckstart" value="eau" />
<label for="feu">Air :</label>
<input type="radio" id="deckstart" name="deckstart" value="air" />
</td>
</tr>
<tr>
<td></td>
<td align="center">
<br />
<input type="submit" name="forminscription" value="Inscription" />
</td>
</table>
</form>
<?php
if(isset($erreur))
{
echo '<font color="red">'.$erreur."</font>";
}
?>
</body>
</html> |
Partager