Jump to content

Logging in


westminster86

Recommended Posts

Why is that the line, if ($result['password']==$password) is returning false? It finds the email address, but theres no match between the passwords.

 


<?php
  session_start();

  $email = $_POST['email'];
  $password = $_POST['password'];

  if (!$email || !$password)
  {
    echo '<p>You have not entered search details. <a href="login.php">Please go back and try again.</a></p>';
    exit;
  }

  $dbhandle = sqlite_popen("", 0666, $err_msg);
  if(!$dbhandle) die("Could not open the database");

  $query = sqlite_query($dbhandle, "SELECT * FROM users WHERE emailaddress='$email'");
  $result = sqlite_fetch_all($query, SQLITE_ASSOC);

  if (sqlite_num_rows($query)==0)
  {
    // invalid email address
  }
  else
  {

  if ($result['password']==$password)
  {
    // create session variable
  {

  }

  }
  else
  {
    // invalid password
  }

  }
?>

Link to comment
Share on other sites

a very quick and dirty debug with if statements would probably present a slotio, echo the two variables before comparing to make sure it is what you expected, also: priint_r($result); try that between the query and the problem if statement,

 

tell us what it says :)

Link to comment
Share on other sites

I assume the password is being stored unencrypted. but you may want to do a little cleanup on the posted password to make sure no spaces are in it or unwanted characters. Echo out the form password and the database password and see what you get.

 

Ray

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.