PHP Login script

Posted In PHP
  • dennis-aarts 3 years ago

    Hi,

    First of all: Awesome tutorial :), but i have a problem.

    The register part works, all entries go into the db. The problem lies in the login script.

    It keeps throwing the error Die(), but everything is the same as in the tutorial.

    When i var_dump count its says int(1).

    I don't know whats wrong..

    Pls Help!

    Thnx, Dennis

     
     
     <?php
    error_reporting(E_ALL);
    require('db-config.php');
    
    if( !empty($_POST['email']) && !empty($_POST['password']) ):
        $records = $conn->prepare('SELECT id,email,password FROM users WHERE email = :email');
        $records->bindParam(':email', $_POST['email']);
        $records->execute();
        $results = $records->fetch(PDO::FETCH_ASSOC);
    
        if( count($results) > 0 && password_verify($_POST['password'], $results['password']) ) {
            die('We have a login');
        }else{
            die('Error while logging user in');
        }
    endif;
    ?>
  • dennis-aarts 3 years ago

    Ah never mind, I found it!

    Didnt turn on PDO Exeptions, so didnt see any error. My query threw an error because the id in my dbtable had a different name =)

     

    Sorry!

  • susan-byrd 3 weeks ago
    I invite you to your first blog and I regard your respect for inclining PHP abilities and doing a venture on it and actually your article is amazing with respect to the first run through and now [wise essays](https://awriter.org/wiseessays-com-review/) services provides quality work. Do share and raise new viewpoints on various points.

    I invite you to your first blog and I regard your respect for inclining PHP abilities and doing a venture on it and actually your article is amazing with respect to the first run through and now wise essays services provides quality work. Do share and raise new viewpoints on various points.

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!