Create a password generator by yourself in php:

Here is the code for Create a password generator :



<?php
  function generate_password($length)
    {
        $alpha=array('q','p','Z','o','R','*','&','@');
        $password='';
        for($i=1;$i<=$length;$i++)
        {
            $rand_value=rand(0,7);
            echo '----'.$rand_value."<br/>";
            $password .=$alpha[$rand_value];
           
        }
        return $password;
    }

?>

<html>
    <head>
        <title>Generate Password</title>
    </head>
    <body>
        <form action="generate_password.php" method="post">
        <table>
          
            <tr>
                <td>
                    <input type="text" name="length">
                </td>
            </tr>
           
            <tr>
                <td>
                    <input type="submit" name="btn" value="Generate password">
                </td>
            </tr>
            <tr>
                <td>
                    <?php
                    if(isset($_POST['btn']))
                    {
                       
                        echo generate_password($_POST['length']);
                    }
                   
                    ?>
                </td>
            </tr>
        </table>
        </form>
    </body>
</html>

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!