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
|
<?php
// on teste si le visiteur a soumis le formulaire
if (isset($_POST['inscription']) && $_POST['inscription'] == 'I create my account') {
// on teste l'existence de nos variables. On teste également si elles ne sont pas vides
if ((isset($_POST['email']) && !empty($_POST['email']))
&& (isset($_POST['password']) && !empty($_POST['password']))
&& (isset($_POST['titre']) && !empty($_POST['titre']))
&& (isset($_POST['prenom']) && !empty($_POST['prenom']) && strlen($_POST['prenom'])>4)
&& (isset($_POST['nom']) && !empty($_POST['nom']) && strlen($_POST['prenom'])>4)
&& (isset($_POST['pass_confirm']) && !empty($_POST['pass_confirm']))) {
// on teste les deux mots de passe
if(!empty($_POST) && strlen($_POST['prenom'])<4){
$error_prenom = ' Votre prenom doit comporter au minimun 4 caracteres !';
}
if(!empty($_POST) && strlen($_POST['nom'])<4){
$error_nom = ' Votre nom doit comporter au minimun 4 caracteres !';
}
if(!empty($_POST) && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$error_email = ' Votre Email n\'est pas valide !';
}
if(!empty($_POST) && strlen($_POST['password'])<6){
$error_password = ' Votre password doit comporter au minimun 6 caracteres !';
}
if ($_POST['password'] != $_POST['pass_confirm']) {
$erreur = 'Les 2 mots de passe sont différents.';
}
else {
$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 {
$erreur = 'Un membre possède déjà ce login.';
}
}
}
else {
$erreur = 'Au moins un des champs est vide.';
}
}
?>
<html>
<head>
<title>Inscription</title>
</head>
<body>
<div id="contour_formulaire">
<form action="inscription.php" method="post">
<fieldset style="border-color:#73aad2;border-size:2px;" width="625">
<legend class="titre_labelaut">Open your personal Interchim web account & get benefit of many advantages :</legend>
<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($error_prenom)){ echo $error_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"><?php if(isset($error_nom)){ echo $error_nom; } ?>
</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"><?php if(isset($error_email)){ echo $error_email; } ?>
</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"><?php if(isset($error_password)){ echo $error_password; } ?>
</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"><?php if(isset($error_password)){ echo $error_password; } ?>
</td>
</tr>
<tr>
<td> </td>
<td colspan="5"><?php if (isset($erreur)) echo '<br />',$erreur; ?></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>
</fieldset>
</form><br/>
</div>
</body>
</html> |
Partager