Page 3 of 3

Re: One Time Password

Posted: Wed Nov 30, 2011 11:36 am
by Celauran
Celauran wrote:Unless you have defined them as constants somewhere, you'll need quotes around your MySQL login credentials.

You have

Code: Select all

if ($peanut == $password)
but I don't see $password defined anywhere, so the comparison will always fail.

You've defined a function that never gets called. You've queried the database but aren't doing anything with the result ($result). Is this the complete code?

Re: One Time Password

Posted: Wed Nov 30, 2011 12:24 pm
by ebgames56
yes this is the complete code i have

Re: One Time Password

Posted: Wed Nov 30, 2011 12:38 pm
by ebgames56
do you want me to post that code i have again for you

Re: One Time Password

Posted: Wed Nov 30, 2011 12:42 pm
by Celauran

Code: Select all

$result = mysql_query("SELECT * FROM Codes") or die(mysql_error());
What is the purpose of this? You're querying the database but doing nothing with the results.

Code: Select all

function get_rand_letters($length)
{
    if ($length > 0)
    {
        $rand_id = "";
        for ($i = 1; $i <= $length; $i++)
        {
            mt_srand((double) microtime() * 1000000);
            $num = mt_rand(1, 5);
            $rand_id .= assign_rand_value($num);
        }
    }
    return $rand_id;
}
This function is never called. Why is it here?

Code: Select all

    if ($peanut == $password)
This will always fail because $password is never defined.

The password your users are supposed to enter, where is it coming from? Where is it being stored? How do you ensure it can only be used once?

Re: One Time Password

Posted: Wed Nov 30, 2011 12:44 pm
by ebgames56
it is coming from the database Purchase table codes

and i not sure how to make it only used once.

and that $length is for to generate random codes like 0983843 to put in the text box

Re: One Time Password

Posted: Tue Dec 06, 2011 12:55 am
by mdiendd123456
ebgames56 wrote:I need a script to make a one time password but with a bunch of passwords only to be able to use once to download a file.

Thanks

i cant get it to well see i have a database with number passwords its just not letting me login in with the numbers

Re: One Time Password

Posted: Fri Dec 09, 2011 3:41 am
by phphelpme
You need to listen to 'Celauran' as your code does nothing at the moment just like 'Celauran' is trying to tell you.

It would be easier to create your download link, email to user, save link code to database, set dl=0, when user clicks link code sets dl=1, when they try click link again your code would recognise dl=1 in database and the link would not work.

You can have your code do this automatically for you so you don't need to do anything with your database once you have coded it.

Seriously, listen to 'Celauran' and you might get what you want buddy. :)