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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
<?php
// Initialisation des variables -isset détermine si variable est définie et différente de null
$email = isset($_POST['email']) ? $_POST['email'] : '' ;
$password = isset($_POST['password']) ? $_POST['password'] : '' ;
$titre = isset($_POST['titre']) ? $_POST['titre'] : '' ;
$prenom = isset($_POST['prenom']) ? $_POST['prenom'] : '' ;
$nom = isset($_POST['nom']) ? $_POST['nom'] : '' ;
$pass_confirm = isset($_POST['pass_confirm']) ? $_POST['pass_confirm'] : '' ;
$erreur = isset($erreur) ? $erreur : '' ;
{
// Test des champs du formulaire
if (isset($_POST['inscription']) && $_POST['inscription'] == 'I create my account') {
// Construction du tableau d'erreurs
$erreur = array(0 => 'prenom',
1 => 'nom',
2 => 'email',
3 => 'password',
4 => 'password2');
// on teste les deux mots de passe
if(!empty($_POST) && strlen($_POST['prenom'])<4){
$erreur['prenom'] = ' Votre prenom doit comporter au minimun 4 caracteres !';
}
if(!empty($_POST) && strlen($_POST['nom'])<4){
$erreur['nom'] = ' Votre nom doit comporter au minimun 4 caracteres !';
}
if(!empty($_POST) && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$erreur['email'] = ' Votre Email n\'est pas valide !';
}
if(!empty($_POST) && strlen($_POST['password'])<6){
$erreur['password'] = ' Votre password doit comporter au minimun 6 caracteres !';
}
if ($_POST['password'] != $_POST['pass_confirm']) {
$erreur['password2'] = 'Les 2 mots de passe sont différents.';
}
// On enregistre dans la variable '$nb_erreur', le nombre d'erreurs
$nb_erreur = count($erreur);
// Si pas d'erreur
if (!$nb_erreur){
$base = mysql_connect ('localhost', 'root', '');
mysql_select_db ('membres', $base);
// on recherche si ce login est déjà utilisé par un autre membre
$sql = 'SELECT count(*) FROM membre WHERE email="'.mysql_escape_string($_POST['email']).'"';
$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
$data = mysql_fetch_array($req);
// si cet email n'est pas déjà présent dans la table, on peut l'enregistrer $data = 0
if ($data[0] == 0) {
$sql = 'INSERT INTO membre VALUES("",
"'.mysql_escape_string($_POST['email']).'",
"'.mysql_escape_string(md5($_POST['password'])).'",
"'.mysql_escape_string($_POST['titre']).'",
"'.mysql_escape_string($_POST['prenom']).'",
"'.mysql_escape_string($_POST['nom']).'",
"")';
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error());
// et on commence la session qui s'appelle email
session_start();
$_SESSION['email'] = $_POST['email'];
header('Location: inscription2.php');
exit();
}
else {
$erreur2 = 'Un membre possède déjà ce login.';
}
}
}
else {
$erreur2 = 'Au moins un des champs est vide.';
}
}
?>
<html>
<head>
<title>Inscription</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="contour_formulaire">
<form action="inscriptionTest3.php" method="post">
<fieldset style="border-color:#73aad2;border-size:2px;" width="625">
<br/>
<table width="628" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td colspan="6" class="error"></td>
</tr>
<tr>
<td width="132"> <label for="titre" class="TexteLogin">Title : </label></td>
<td width="59" class="TexteCheck"><label><input name="titre" type="radio" value="Mr" checked="checked" />
Mr </label></td>
<td width="80" class="TexteCheck"><label><input name="titre" type="radio" value="Mme" />Mme </label></td>
<td colspan="2" class="TexteCheck"><label><input name="titre" type="radio" value="Mlle" />
Mlle</label></td>
<td width="280" class="error2"></td>
</tr>
<tr>
<td width="132"> <label for="prenom" class="TexteLogin">First Name : </label></td>
<td colspan="3">
<input type="text" name="prenom" class="loginRemplissage" value="<?php if (isset($_POST['prenom'])) echo htmlentities(trim($_POST['prenom'])); ?>">
<span class="error">*</span></td>
<td colspan="2" class="error2"><?php if(isset($erreur)){ echo $erreur['prenom']; } ?></td>
</tr>
<tr>
<td colspan="6" class="error"></td>
</tr>
<tr>
<td width="132"> <label for="nom" class="TexteLogin">Family Name : </label></td>
<td colspan="3">
<input type="text" name="nom" class="loginRemplissage" value="<?php if (isset($_POST['nom'])) echo htmlentities(trim($_POST['nom'])); ?>">
<span class="error">*</span></td>
<td colspan="2" class="error2"> </td>
</tr>
<tr>
<td colspan="6" class="error2"></td>
</tr>
<tr>
<td width="132"> <label for="email" class="TexteLogin">E-mail : </label></td>
<td colspan="3">
<input type="text" name="email" class="loginRemplissage" value="<?php if (isset($_POST['email'])) echo htmlentities(trim($_POST['email'])); ?>">
<span class="error">*</span></td>
<td colspan="2" class="error2"> </td>
</tr>
<tr>
<td colspan="6" class="error"></td>
</tr>
<tr>
<td width="132"> <label for="password" class="TexteLogin">My password : </label></td>
<td colspan="3">
<input type="password" name="password" class="loginRemplissage" value="<?php if (isset($_POST['password'])) echo htmlentities(trim($_POST['password'])); ?>">
<span class="error">*</span></td>
<td colspan="2" class="error2"> </td>
</tr>
<tr>
<td width="132"> <label for="password" class="TexteLogin">Confirm password : </label></td>
<td colspan="3">
<input type="password" name="pass_confirm" class="loginRemplissage" value="<?php if (isset($_POST['pass_confirm'])) echo htmlentities(trim($_POST['pass_confirm'])); ?>">
<span class="error">*</span></td>
<td colspan="2" class="error2"> </td>
</tr>
<tr>
<td> </td>
<td colspan="5"><?php if (isset($erreur2)) echo '<br />',$erreur2; ?></td>
</tr>
<tr>
<td height="43"></td>
<td colspan="5"> <input type="submit" name="inscription" class="AlignementCreateAccount" value="I create my account"/></td>
</tr>
<tr>
<td height="19"> </td>
<td colspan="5"><span class="error">*</span> <span class="error">Must be mandatory filled </span></td>
</tr>
</table>
<p class="TexteFormulaireNombreProduits" id="contour_formulaire"><strong>Confidentiality : </strong><br />
The information you provide to us is strictly confidential and will under no circumstances be disclose or transfer to another person. Our site si only for professionals. </p>
</fieldset>
</form><br/>
</div>
</body>
</html> |
Partager