
le 12/12/2004 à 11:19
inscription & niveau
c'est possible de faire plusieurs niveaux ? un confirmé, l'autre moyen, et un autre nul ! Comme ca on a peut être nos chances :-)
<?php
include('config/bdd.php');
session_start();
if (isset($rediriger)) {
header('Location: '.$rediriger.'');
}
?>
<?php
include('include/application_top.php');
// VERIFICATION DE L'ENVOI DU FORMULAIRE
if (isset($_POST['inscription']) && $_POST['inscription'] == 'inscription'){
// VERIFICATION QUE TOUT LES CHAMPS SOIENT BIEN REMPLI
if (isset($_POST['login']) && !empty($_POST['login']) && isset($_POST['mdp_1']) && !empty($_POST['mdp_1']) && isset($_POST['mdp_2']) && !empty($_POST['mdp_2'])) {
// VERIFICATION QUE LES DEUX MOTS DE PASSES SOIENT IDENTIQUES
if ($_POST['mdp_1'] == $_POST['mdp_2']) {
// VERIFICATION SI CE LOGIN EXISTE DEJA DANS LA BASE
$sql = 'SELECT id FROM membre WHERE login="'.addslashes($_POST['login']).'"';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb = mysql_num_rows($req);
// AFFICHAGE DU RESULTAT
if ($nb == 0) {
// SI AUCUN MEMBRE AVEC LE MEME LOGIN, ON INSCRIT
$sql = 'INSERT INTO membre VALUES("", "'.addslashes($_POST['login']).'", "'.md5(addslashes($_POST['mdp_1'])).'","'.date("Y-m-d").'")';
$req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
$id = mysql_insert_id();
$_SESSION['login'] = $_POST['login'];
$_SESSION['id'] = $id;
$redirection = 'index.php?page=membre';
exit();
}
else
{
// SINON ON AFFICHE UNE ERREUR
$erreur = 'ce pseudo est déjà utilisé, choisis-en un autre';
$redirection = 'index.php?page=inscription_membre';
}
}
else
{
// AFFICHAGE ERREUR DES MOTS DE PASSES
$erreur = 'il faut que les deux mots de passes soient identique';
$redirection = 'index.php?page=inscription_membre';
}
}
else
{
// AFFICHAGE ERREUR QUE LES CHAMPS NE SONT PAS BIEN REMPLI
$erreur = 'il faut remplir tout les champs';
$redirection = 'index.php?page=inscription_membre';
}
}
?>
<form name="inscription_membre" method="post" action="index.php?page=inscription_membre">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><?php if (isset($erreur)) echo 'ERREUR : '.$erreur.''?></td>
</tr>
<tr>
<td width="33%">login</td>
<td width="67%"><input name="login" type="text" id="login" value="<?php if (isset($_POST['login'])) echo stripslashes(htmlentities(trim($_POST['login']))); ?>"> <?php if (isset($_POST['login']) && empty($_POST['login'])) echo '!' ?></td>
</tr>
<tr>
<td>mot de passe </td>
<td><input name="mdp_1" type="password" id="mdp_1" value="<?php if (isset($_POST['mdp_1'])) echo stripslashes(htmlentities(trim($_POST['mdp_1']))); ?>"> <?php if (isset($_POST['mdp_1']) && empty($_POST['mdp_1'])) echo '!' ?></td>
</tr>
<tr>
<td>mot de passe confirmation </td>
<td><input name="mdp_2" type="password" id="mdp_2" value="<?php if (isset($_POST['mdp_2'])) echo stripslashes(htmlentities(trim($_POST['mdp_2']))); ?>"> <?php if (isset($_POST['mdp_2']) && empty($_POST['mdp_2'])) echo '!' ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name="inscription" type="submit" id="inscription" value="inscription"></td>
</tr>
</table>
</form>