Bonjour à tous.... je ne savais pas trop si je devais poster dans cette section, mes excuses à l'avance....

Je suis face à un problème pour ma section REGISTER, en gros:

J'ai 2 étapes en CSS, j'ai l'identifiant en premier, quand je tape au clavier (.keyup) soit il est vide, soit il fait moins de 3 caractères, soit il est déjà dans la BDD et donc il me met un message d'erreur, si tout est bon, il n'y a aucun message d'erreur, et donc à ce moment là je peux cliquer sur le boutton Valider, l'étape une disparait, et l'étape deux apparait...

Ce qui me pose problème par rapport à mon code, c'est que même si l'identifiant est pris, alors il passe quand même à l'étape deux... y aurait t'il quelque chose dans mon code que j'aurai oublié ?

Cordialement.

JQUERY:
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
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
 
$(document).ready(function(){
 
    identifiantRegister_error = true;
 
    $("#identifiantRegister").keyup(function () {
        identifiantRegister_check();
    });
 
 
 
    function identifiantRegister_check() {
        identifiantRegister = $("#identifiantRegister").val();
 
        if(identifiantRegister == "") {
            $("#error_identifiant").addClass("active-error").html("Identifiant obligatoire");
            identifiantRegister_error = false;
            return false;
        } else {
            $("#error_identifiant").removeClass("active-error").html("");
        }
 
        if(identifiantRegister.length < 3) {
            $("#error_identifiant").addClass("active-error").html("Identifiant invalide (4 caractères minimums)");
            identifiantRegister_error = false;
            return false;
        } else {
            $("#error_identifiant").removeClass("active-error").html("");
        }
 
        if(identifiantRegister != "" && identifiantRegister.length >= 3) {
            $.post(
 
                "users/register/check_identifiant_exist.php",
                {
                    identifiantRegister : $("#identifiantRegister").val()
                },
 
                function(data) {
                    if(data == "Success") {
 
                    } else {
                        $("#error_identifiant").addClass("active-error").html("Identifiant déjà pris");
                        identifiantRegister_error = false;
                        return false;
                    }
                },
 
                "text"
 
            );
 
        }
    }
 
    $("#btn_identifiant").click(function() {
        identifiantRegister_error = true;
 
        identifiantRegister_check();
 
        if(identifiantRegister_error == true) {
            $("#register_form #tab1").removeClass("active");
            $(".tabs-list .tab1").removeClass("active");
            $("#register_form #tab2").addClass("active");
            $(".tabs-list .tab2").addClass("active");
            $(".item2").addClass("form-steps__item--completed");
            return true;
        } else {
            return false;
        }
    });
 
    $("#previous_btn_email").click(function() {
        $("#register_form #tab2").removeClass("active");
        $(".tabs-list .tab2").removeClass("active");
        $("#register_form #tab1").addClass("active");
        $(".tabs-list .tab1").addClass("active");
        $("#error_identifiant").text("");
        $(".item2").removeClass("form-steps__item--completed");
    });
 
});
PHP:
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
<?php
$bdd = new PDO("mysql:host=localhost;dbname=login", "root", "");
 
 
if(isset($_POST['identifiantRegister'])) {
 
$identifiantRegister = $_POST["identifiantRegister"];
 
	$req = $bdd->prepare("SELECT * FROM login WHERE username = ?");
	$req->execute(["$identifiantRegister"]);
	$test = $req->rowCount();
 
	if($test > 0) {
		echo "Failed";
	} else {
		echo "Success";
	}
 
}
 
 
?>