Loging Script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
It seems there is something wrong with my script for the reason that
it always returns, UserName NOT found . I know it connects to the db
fine because I don't get a error. So just been trying to figure out
what's wrong. I am using PEAR btw.

Pastebin: http://pastebin.ca/360410


require 'DB.php';

$db = DB::connect('mysql://lol:lol@localhost/user');

if (DB::isError($db)) : ' . $db-
Quoted text here. Click to load it

$user = $_POST['user'];
$password = md5($_POST['password']);
$password2 = md5($_POST['password2']);

$sql = check();

function check()
    global $db;
    global $user;

$rows = $db->getAll('SELECT user_name FROM user');
if (DB::isError($db)) : ' . $db->getMessage());}

                        if(array_key_exists("$user", $rows)){print "<p><b>UserName
AcceptED</b>";}else{print "<p><b>UserName NOT found</b>";}

                }else{print "<p>no username was typed";}



Re: Loging Script

phyburn wrote:

Quoted text here. Click to load it

By the time it got to me this had some very unusual formatting - I'd
recommend sticking to the PEAR style guidelines, particularly when posting
to newsgroups.

Quoted text here. Click to load it

You should be looking for a value, not a key - and getAll returns a nested
array - i.e. somewhere there should be...


But really you should be checking this in the SQL - not loading a list of
all users then checking in PHP.


Re: Loging Script

Quoted text here. Click to load it

Untested, I seldomly use PEAR::DB:

$stmt = $db->prepare('SELECT user_name, password FROM user WHERE user_=
name  =

=3D ?');
$result = $db->execute($stmt,$user);
if($result->numRows()!=3D1) die('Username not found or multiple users wi=
th  =

the same name.');
-- =

Rik Wasmus

Site Timeline