Google Answers Logo
View Question
 
Q: Find a bug in this PHP lost password sending code ( No Answer,   0 Comments )
Question  
Subject: Find a bug in this PHP lost password sending code
Category: Computers > Programming
Asked by: oldman-ga
List Price: $7.00
Posted: 05 Feb 2004 22:44 PST
Expires: 06 Feb 2004 15:47 PST
Question ID: 304026
Hello!

If you are good at PHP, please have a look at the code below:

This is a utility that is supposed to send you your forgotten
password. You just have to provide your username or email. However, I
have modified it so that if there are multiple members using the same
e-mail address in the database, the notification will be sent to each
one of them. Unfortunately, my modifications don't work and now this
code will not send the notification even once. Do you know what can be
wrong?

include('./config.inc.php');
$t = & new_smarty();

$vars = get_input_vars();
$login = $vars['login'];

if (!strlen($login)) {
    $t->assign('login', $login);
    $t->display('sendpass_failed.html');
    exit();
};

$ul = $db->users_find_by_string($login, 'login', 1);
if (!count($ul)){
    $l = $db->escape($login);
    $q = $db->query("SELECT m.member_id, p.expire_date
        FROM {$db->config[prefix]}members m LEFT JOIN
            {$db->config[prefix]}payments p USING (member_id)
        WHERE m.email='$l'
        GROUP BY m.member_id
        ORDER BY p.completed DESC, p.expire_date DESC
        ");
    while (list($member_id, $expire) = mysql_fetch_row($q)){
        $ul[] = $member_id ? array($db->get_user($member_id)) : array();
    }
}
if ( count($ul) ){
    foreach ($ul as $u){
        $t->assign('login',  $u['login']);
        $t->assign('pass',   $u['pass']);
        $t->assign('email',  $u['email']);
        $t->assign('name_f', $u['name_f']);
        $t->assign('name_l', $u['name_l']);
        $t->assign('user', $u);
        $msg = $t->fetch("sendpass.txt");
        $admin_email = $config['admin_email'];
        mail_customer($u['email'], $msg, "Password Remainder");
    }
    $t->display('sendpass_ok.html');
} else {
    $t->assign('login', $login);
    $t->display('sendpass_failed.html');
}

Request for Question Clarification by poe-ga on 06 Feb 2004 02:38 PST
Hi Oldman,

There's one obvious error that leaps out. I don't know enough about
PHP to say with surety whether it will solve your problem, but it's
certainly something that needs fixing.

Your first IF statement ends with }; as shown below:

if (!strlen($login)) {
    $t->assign('login', $login);
    $t->display('sendpass_failed.html');
    exit();
};

I would recommend removing the semi colon so that it reads like this:

if (!strlen($login)) {
    $t->assign('login', $login);
    $t->display('sendpass_failed.html');
    exit();
};

Let me know if this works or if I need to look further.

And as always with problems like this, it's always something simple.
It's just that there's about ten billion simple things that it could
be...

Poe

Request for Question Clarification by poe-ga on 06 Feb 2004 02:39 PST
Oops. My copy and paste didn't work as it should have done.

Removing the semi colon should make the statement read as follows:

if (!strlen($login)) {
    $t->assign('login', $login);
    $t->display('sendpass_failed.html');
    exit();
}

Sorry about that.

Poe
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy