<?php

// Use logic for the POST values

if(isset($_POST['submit']))
{
    if(!empty(
$_POST['length']) && is_numeric($_POST['length']))
    {

        echo 
'<h2>Results</h2>'"\n";

        
$chars 'a b c d e f g h i j k l m n o p q r s t u v w x y z';
        if(isset(
$_POST['numbers']))
            
$chars .= '0 1 2 3 4 5 6 7 8 9';
        if(isset(
$_POST['case']))
            
$chars .= 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
        if(
$_POST['characters'] == 1)
            
$chars .= '$ # @ = - _';
        elseif(
$_POST['characters'] == 2)
            
$chars .= '$ $ $ # # # @ @ @ = = = - - - _ _ _';

        require 
'class.passgen.php';
        
$pass = new passgen($_POST['length'], $chars);

        echo 
'<table summary="Generated password results"><tr><th>Type</th><th>Value</th></tr><tr><td>Generated password</td><td>' $pass->showpass() . '</td></tr>';

        if(isset(
$_POST['md5']))
            echo 
'<tr><td>MD5 hash</td><td>'$pass->createhash('MD5'), '</td></tr>';
        if(isset(
$_POST['sha1']))
            echo 
'<tr><td>SHA-1 hash</td><td>'$pass->createhash('SHA1'), '</td></tr>';
        if(isset(
$_POST['sha256']))
            echo 
'<tr><td>SHA-256 hash</td><td>'$pass->createhash('SHA256'), '</td></tr>';

        echo 
'</table>';

    }

    else
        echo 
'<p>Please enter a valid length.';

}

?>