<?php
/*
    Program generates a random password.
    Default password length is 8.
    I'm using mt_rand with php's default seeding process so our results should be very random.
    Written by Jason Lancaster
*/

function randstr($max) {
    
$chars 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%&*';
    
$pass '';
    for (
$i=0$i<$max$i++) 
        
$pass .= $chars[(mt_rand(0,(strlen($chars)-1)))];
    return 
$pass;
}

if (!
$_REQUEST['max']) $_REQUEST['max'] = 8;
printf("Your password is: <input type=text name=password value=\"%s\" size=%d><br>\n"
    
randstr($_REQUEST['max']), $_REQUEST['max'] + 10);
printf("<form action=\"%s\" name=submit>"
    
$_SERVER['PHP_SELF']);
echo 
"Regenerate page with length of: ";
printf("<input type=text name=max value=%d size=5>"
    
$_REQUEST['max']);
echo 
"<input type=submit value=submit></form>\n";
printf("<a href=\"%ss\">View the source</a><br>\n"
    
$_SERVER['PHP_SELF']);
?>