lundi 28 octobre 2019

Why this PHP code return me always the same echo?

This code is a part of registration code. But it return always "Nickname already exist". I don't understand why.

if (isset($_POST['create'])) { 

        $nickname       = $_POST['nickname'];
        $email          = $_POST['email'];
        $password       = $_POST['password'];

        $slt1 = "SELECT nickname FROM users WHERE nickname='$nickname'";
        $slt2 = "SELECT email FROM users WHERE email='$email'";
        $stmt1 = $db->prepare($slt1);
        $stmt2 = $db->prepare($slt2);
                                        

                if($stmt1->execute([$nickname])) {

                    echo 'Nickname already exist';

                } elseif ($stmt2->execute([$email])) {

                        echo 'email already exist';

                } else {

                        //more code here                        
                                                                
                }
                                        
        }       

Aucun commentaire:

Enregistrer un commentaire