View difference between Paste ID: Zt4ky7cP and cDzY6png
SHOW: | | - or go back to the newest paste.
1-
if(isset($_GET['c'],$_GET['email'],$_GET['p'],$_GET['n'])){
1+
2-
		extract($_GET);
2+
function add_user($nom,$prenom,$email){
3-
		$prenom = base64_decode($p);
3+
4-
		$nom = base64_decode($n);
4+
	$stmt = $GLOBALS['bdd']->prepare("SELECT email FROM users WHERE email=:email");
5-
		$email = base64_decode($email);
5+
	$stmt->execute(array(':email'=>$email));
6-
		$confirm = base64_decode($c);
6+
7-
		ob_start();
7+
	if($stmt->rowCount() == 0){
8-
		if($confirm == "validate"){
8+
		$rsp = $GLOBALS['bdd']->prepare("INSERT INTO users(nom,prenom,email) VALUES(:nom,:prenom,:email)");
9-
			if(add_user($nom,$prenom,$email)){
9+
		$rsp->execute(array(
10-
				//modal window success
10+
			':nom' => $nom,
11-
				header('Location: index.php?s=' . base64_encode('success'));
11+
			':prenom' => $prenom,
12-
			}else{
12+
			':email' => $email
13-
				//modal window fail
13+
			));
14-
				header('Location: index.php?s=' . base64_encode('error'));
14+
15-
			}
15+
		return true;
16-
		}
16+
	}else{
17-
		ob_end_flush();
17+
		return false;
18-
		
18+
19
20-
	if(isset($_GET['s'])){
20+
21-
		extract($_GET);
21+
}