Login to php [closed]

1

Next, I'm developing a work for the course and I'm creating a login system, it is working when I send it, however every time I enter the page again through localhost it creates a line with blank data and as a result ends using an unnecessary line and occupying one of the codes (auto_increment). The following is the page: (with bootstrap)

link

db: table users only have name and password as varchar.

Thank you in advance!

    
asked by anonymous 17.11.2016 / 20:39

1 answer

0

Your PHP code should be changed

    ob_start();
    include ('conect.php');
    if(isset($_POST['nome']) and isset($_POST['senha'])){
        $nome = isset($_POST['nome']) ? $_POST['nome'] : '';
        $senha = isset($_POST['senha']) ? $_POST['senha'] : '';
        $sql = "insert into usuarios (nome, senha) values ('$nome', '$senha')";
        mysql_query($sql) or die(mysql_error());
    }

In the case of isset we first check if there is a name and password to be included, if applicable, inserts into the database, thus avoiding unnecessary lines in the database.

    
17.11.2016 / 20:58