0
I am making a virtual sales store using HTML/CSS/PHP for the course work and am getting the following BUG:
I created the code for the processing of user registration, when I create the first user works and creates the data in the database. Everything works beautiful, but when I create another user does not work, does not create.
<?php 
// Vai incluir/importar a função/método que está no Conexao.php
    include 'Includes\Conexao.php';
// Receber o login, senha, nome, cpf, endereco e telefone
    $login = $_POST["login"];
    $senha = $_POST["senha"];
    $nome = $_POST["nome"];
    $cpf = $_POST["cpf"];
    $endereco = $_POST["endereco"];
    $telefone = $_POST["telefone"];
// Consulta se o login já é existente no banco de dados
    $consulta = mysql_query ("SELECT loginUser FROM usuarios WHERE loginUser = '$login'");
    $linhas = mysql_num_rows ($consulta); // Coloca na variável um valor com a quantidade de linhas encontradas na consulta feita anteriormente
// Se o resultado for verdadeiro, se existir o login no banco de dados, ele retornará uma mensagem e volta para a página Cadastra_User.php
    if ($linhas == 1) // ou true - Se o login existir
    {
        echo "<script> alert ('Login ja cadastrado com algum usuario. Tente novamente!') </script>";
        echo "<script> location.href = ('Cadastra_User.php') </script>";
        exit(); // se for verdadeiro, o fluxo para aqui!
    }
    else // Se o login não existir
    {
        $cadastrar = mysql_query("INSERT INTO usuarios (loginUser, senhaUser, nomeUser, cpfUser, endereco, telefone) VALUES ('$login', '$senha', '$nome', '$cpf', '$endereco', '$telefone')");
        if ($cadastrar == true)
        {
            echo "<script> alert ('$nomeUser cadastrado com sucesso!') </script>";
            echo "<script> location.href = ('Cadastra_User.php') </script>";
            exit(); // se for verdadeiro, o fluxo para e retorna para a página de cadastra_user
        }
        else
        {
            echo "<script> alert ('Ocorreu um erro no servidor. Tente novamente!') </script>";
        }   
    }       
?>
What appears when I try to create a second user:

See how sql was mounted on the second call, use
mysql_errorto show which error occurred– fernandoandrade
you have an auto increment? field before writing the error message do,
echo mysql_error();– rray