Author Topic: [SOLVED] Login Error  (Read 176 times)

0 Members and 1 Guest are viewing this topic.

Offline balloutaTopic starter

  • Devotee
  • Gender: Male
    • View Profile
[SOLVED] Login Error
« on: September 30, 2008, 01:41:21 PM »
Hello

Code: [Select]
my login code is not working, i couldn't find the problem yet, please help:
Code: [Select]
<?php
if($_POST){ 
  
$_SESSION['username']=trim($_POST["user"]);
  
$_SESSION['password']=trim($_POST["pass"]);
}

//check if the username and password exist or not
$result=mysql_query("select * from `members` where user COLLATE latin1_bin ='" $_SESSION['username'] . "' AND pass COLLATE latin1_bin ='" $_SESSION['password'] . "'"); 

// retrieve number of rows resulted 
$num=mysql_num_rows($result);  

$row mysql_fetch_array($result);

// print login form and exit if failed. 
if($num 1){
                  
              
if ($row[reseller] == 'Y') {
                                         
//display smthg related to reseller
             
} else {
                     
// user not a reseller
                     
}

             } 
// end if num>1

else {
echo 
"user not found";
}

?>


i am getting user not found. WHY?
Thank you

Online PFMaBiSmAd

  • PHPFreaks Recommended
  • Freak!
  • *
    • View Profile
Re: Login Error
« Reply #1 on: September 30, 2008, 02:06:52 PM »
Start by adding the following two lines immediately after your first <?php tag -

Code: [Select]
ini_set ("display_errors", "1");
error_reporting(E_ALL);
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

Offline revraz

  • Freak!
  • Gender: Male
  • Problems Resolved: 295
    • View Profile
Re: Login Error
« Reply #2 on: September 30, 2008, 02:41:23 PM »
My first guess is because you don't start sessions anywhere.
If I can't make it better, then I'll make it worse, but it definitely won't be the same.

Offline balloutaTopic starter

  • Devotee
  • Gender: Male
    • View Profile
Re: Login Error
« Reply #3 on: September 30, 2008, 02:42:22 PM »
yes sorry i forgot to start the session :(

thanks alot

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.