thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Video 28 - Password #121

Closed RosemaryRoss closed 9 years ago

RosemaryRoss commented 9 years ago

I cannot figure out WHY the log in won't work. I swear I have the code exactly like the video. But I get an error.
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\aptana\AtomCMS\admin\login.php on line 14

Line 14 in the following code is the: if(mysqli_num_rows($r) == 1) {

if($_POST){

$q = "SELECT * FROM users WHERE email = '$_POST[email]' AND password = SHA!('$_POST[password]')";
$r = mysqli_query($dbc, $q);

if(mysqli_num_rows($r) == 1) {

    $_SESSION['username'] = $_POST['email'];
    header('Location: index.php');      

}

}

Help!!

JasonMate commented 9 years ago

You need to use SHA1(), not SHA!()

On Sat, May 23, 2015 at 6:38 PM, Rose notifications@github.com wrote:

I cannot figure out WHY the log in won't work. I swear I have the code exactly like the video. But I get an error.

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\aptana\AtomCMS\admin\login.php on line 14

Line 14 in the following code is the: if(mysqli_num_rows($r) == 1) {

if($_POST){

$q = "SELECT * FROM users WHERE email = '$_POST[email]' AND password = SHA!('$_POST[password]')"; $r = mysqli_query($dbc, $q);

if(mysqli_num_rows($r) == 1) {

$_SESSION['username'] = $_POST['email'];
header('Location: index.php');

}

}

Help!!

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/121.

RosemaryRoss commented 9 years ago

Oh....I HATE when I do stupid things like that. I stared at that for hours and didn't see it. Thanks. Happy Memorial day.