Why does not the error message appear?

2

I am training a php code for user registration, where the required fields are validated but only the return of the login field that uses the remote command: it does not print the result, here are the codes I am using:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Cadstro de usuarios</title>
    <link href="theme/css/principal.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.11.3.js" type="text/javascript"></script>
    <script src="js/jquery.validate.js" type="text/javascript"></script>
    <script>
        $(document).ready(function() {
            $("#idForm").validate({
                // Define as regras
                rules: {
                    txtNome: {
                        required: true,
                        minlength: 4
                    },
                    txtEmail: {
                        required: true,
                        email: true
                    },
                    txtLogin: {
                        required: true,
                        minlength: 4,
                        remote: 'checa_login.php'

                    },
                    txtSenha: {
                        required: true,
                        minlength: 4
                    },
                    rep_senha: {
                        required: true,
                        equalTo: "#txtSenha"
                    }
                },
                // Define as mensagens de erro para cada regra
                messages: {
                    txtNome: {
                        required: 'Digite o seu nome',
                        minlength: 'O seu nome deve conter, no mínimo, 4 caracteres'
                    },
                    txtEmail: {
                        required: 'Digite o seu e-mail para contato',
                        email: 'Digite um e-mail válido'
                    },
                    txtLogin: {
                        required: 'E necessario cadstrar um login',
                        minlength: 'O seu login deve conter, no mínimo, 4 caracteres',
                        remote: 'Este login ja esta em uso.'
                    },
                    txtSenha: {
                        required: 'Digite uma senha',
                        minlength: 'A senha deve ter no mínimo, 4 caracteres'
                    },
                    rep_senha: {
                        required: 'Repita sua a mesma senha',
                        equalTo: 'A senha n&atilde;o &eacute; igual a anterior.'
                    }
                }
            });
        });
    </script>
</head>
<body>
    <form action="" method="post" name="idForm" id="idForm">
        <fieldset id="centro">
            <legend>Cadastro de novo usuário</legend>
            <label for="nome">Nome: *</label>
            <input id="nome" name="txtNome" type="text" />
            <br />
            <label for="email">E-Mail: *</label>
            <input id="email" name="txtEmail" type="text" />
            <br />
            <label for="login">Login: *</label>
            <input id="login" name="txtLogin" type="text" />
            <br />
            <label for="senha">Senha: *</label>
            <input id="txtSenha" name="txtSenha" type="password" />
            <br />
            <label for="rep_senha">Re-digitar senha: *</label>
            <input id="rep_senha" name="rep_senha" type="password" />
            <br>
            <br />
            <input name="cmd" type="submit" id="cmd" value="Cadastrar" />
        </fieldset>
    </form>
</body>

</html>

The php code that checks for the existence of the login is this:

<?php
    include_once( 'login/conect.php' ); 
    $result = '';
    $username = $_GET['txtLogin'];
    $db = conect::getInstance(); 
    $e = $db-> prepare ( "SELECT * FROM  'login' WHERE login ='$username'" ); 
    $e->bindParam(':username', $username);
    $e -> execute ( ) ; 
    if ($e->rowCount() > 0 ){
        echo json_encode('Login ja em uso.');
        exit;
    }else{
        echo json_encode('true');
        exit;
    }
?>

I needed to put exit; to disappear with the line break that was coming along. The strange thing is that only remote is not working on empty or size checking, it works correctly because it prints on the screen properly.

    
asked by anonymous 24.09.2015 / 05:55

0 answers