<html><body onLoad="document.MyForm.Length.focus()">
<?php

echo <<< Begin

<center>

<table width=50%>
<tr><td><center>

<fieldset>
<B><legend>Password Generator</legend></B>
<FORM ACTION="{$_SERVER['PHP_SELF']}" METHOD="POST" name="MyForm">

Enter the length of the password: 
<input name="Length" size=30>
<P>

Enter the number of passwords:
<input name="Number" size=30>
<P>
<input name="submitted" TYPE="hidden" value="TRUE">
<P>
<input type="submit" VALUE="SUBMIT"> 
<input type="reset" VALUR="RESET">
</form>
</fieldset>

Begin;

if (isset($_POST['submitted'])) // If the form is submitted
{
        $length = (integer) trim($_POST['Length']);
        $number = (integer) trim($_POST['Number']);
        echo "You requested: $number passwords each of length $length.\n<P>";
        if ($length > 0 && $number > 0)
        {
		echo "<B>Here they are:</B><P>\n";
                for ($i = 0; $i < $number; $i++)
                {
                        $pass = "";
                        for ($j=0; $j < $length; $j++)
                        {
                                $n =chr(mt_rand(65,90));
                                $pass = $pass.$n;
                        }
                        echo "<P>$pass\n";
                }
        }
        else
                echo "<P><B> You have to enter positive integers.<P>\n";
	echo "</center></td></tr></table></center>\n";
}

?>
</body></html>
