je veux verifier si l'utilisateur est deja exister et j'ai utilisé ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php 
include('include/cnx-bdd.php');
if(isset($_POST['envoyer'])) {
	if((!empty($_POST['nom']))  AND (!empty($_POST['prenom']))  AND (!empty($_POST['tel'])) AND (!empty($_POST['email'])) AND (!empty($_POST['ma_liste']))  AND (!empty($_POST['sexe']))   AND (!empty($_POST['username'])) AND (!empty($_POST['password'])) AND (!empty($_POST['repeatpassword']))){
		if($_POST['password'] == $_POST['repeatpassword'] ){
			$test = $bdd->prepare('SELECT COUNT( * ) as nb from membre where username= ?');
			$test->execute(array($_POST['username']));
			$test1 = $test->fetch(PDO::FETCH_OBJ);
			if($test1 > 0){
				$ins = $bdd->prepare('INSERT INTO membre (nom,prenom,tel,email,filier,sexe,username,password) VALUES (?,?,?,?,?,?,?,?)');
				$ins->execute(array($_POST['nom'],$_POST['prenom'],$_POST['tel'],$_POST['email'],$_POST['ma_liste'],$_POST['sexe'],$_POST['username'],$_POST['password']));
				header('location:index.php');
			}
			else{
				echo' <strong><p style="color:red">*cette utilisateur  est  déja  existé</p></strong>';							
			}
		}
		else{
			echo ' <strong><p style="color:red">*veuillez verfier votre password </p></strong>'; 
		}
	}
	else {
		echo 'veuillez remplie tout les  champs ';
	}
}
?>