One Time Password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: One Time Password

Post 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?
ebgames56
Forum Contributor
Posts: 103
Joined: Thu Oct 06, 2011 10:43 am

Re: One Time Password

Post by ebgames56 »

yes this is the complete code i have
ebgames56
Forum Contributor
Posts: 103
Joined: Thu Oct 06, 2011 10:43 am

Re: One Time Password

Post by ebgames56 »

do you want me to post that code i have again for you
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: One Time Password

Post 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?
ebgames56
Forum Contributor
Posts: 103
Joined: Thu Oct 06, 2011 10:43 am

Re: One Time Password

Post 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
mdiendd123456
Forum Newbie
Posts: 1
Joined: Tue Dec 06, 2011 12:48 am

Re: One Time Password

Post 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
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: One Time Password

Post 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. :)
Post Reply