You might want to format the code so that it is readable, e.g.,
session_start();
for ($x = 'a'; $x < 'z'; $x++)
{
$s[] = $x;
}
for ($x = 'A'; $x < 'Z'; $x++)
{
$s[] = $x;
}
for ($x = 1; $x < 9; $x++)
{
$s[] = $x;
}
$number = "";
for ($i = 1; $i <= 5; $i++)
{
$number .= $s[mt_rand(1,55)];
}
$_SESSION['test'] = $number;
echo $number;
?>
jansky wrote:the $_SESSION['test'] is not same as the generated value
In what way does it differ?
EDIT:
By the way, those three consecutive loops can be simplified to:
$s = array_merge(range('a', 'y'), range('A', 'Y'), range(1, 8));
Is there any reason not to use 'z', 'Z', 0 and 9? I can see why you might not want to use 0 given that it can be confused with 'O', but 9 seems obviously distinguishable under any reasonable font. Plus, you should use mt_rand(0, count($s) - 1), possibly with count($s) - 1 moved out of the loop.