Secure login

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

Post Reply
Elia
Forum Newbie
Posts: 1
Joined: Tue Apr 20, 2004 2:31 am
Location: Sweden

Secure login

Post by Elia »

I can't see how this code will generate a random string of 10 characters. I can only see how it will generate a random string 10 times and replace the existing one. Would be glad if anyone could tell me what I don't see.


<?php
srand(); //behövs ej i nyare php-versioner
$rnd_str = "";
for ($i=0;$i<10;$i++)
{
if (mt_rand(1,3) == 1)
$rnd_str = $rnd_str.chr(mt_rand(97,122)); //gemener
else if (mt_rand(1,3) == 2)
$rnd_str = $rnd_str.chr(mt_rand(65,90)); //versaler
else
$rnd_str = $rnd_str.chr(mt_rand(48,57)); //siffror
}
$_SESSION['chal'] = $rnd_str; //Spara strängen i sessionvariabeln
?>

Edit:
I see it now :)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please may i direct you to read this - viewtopic.php?t=21171

Read it VERY CAREFULLY

Thanks

Mark
Post Reply