Page 1 of 1

Secure login

Posted: Tue Apr 20, 2004 2:31 am
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 :)

Posted: Tue Apr 20, 2004 3:08 am
by JayBird
Please may i direct you to read this - viewtopic.php?t=21171

Read it VERY CAREFULLY

Thanks

Mark