Login registration in php

Asked

Viewed 54 times

1

Following staff, I am developing a work for the course and I am creating a login registration system, is working when sending, but each time I enter the page again by the localhost it creates a line with blank data and as a consequence ends up using a line unnecessary and occupying one of the codes (auto_increment). Below is the page: (you have bootstrap)

http://pastebin.com/DLkCg2RY

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

Thank you in advance!

  • 1

    Put the code here too !!! Link here is not very recommended if the same is a main item of your doubt, only even as references

  • The code is cutting in php, it is my first time in the forum, to avoid errors pasted the code in Pastebin.

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 are name and password to be included, if applicable, enter in the database, thus avoiding, unnecessary lines in the database.

  • It worked, thank you very much!

  • Okay, fine. Mark my answer as right.. (just click on a checkbox next to my answer) :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.