Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to generate random password using PHP and MySQL

by
Category:php
php html
How to generate random password using PHP and MySQL

This tutorial concerns how to generate online secure and strong random password via PHP and to mail it to anybody’s email ID when they forgot their password. Also, once the user log in to his/her account using auto-generated password. You may also like Forgot Password System using PHP and How to Create Password Protected Webpage Using PHP.

HTML Code

<html>
    <head>
    </head>
    <body>
        <form method="post"action="generate_password.php">
            <input type="text" name="name" id="name" placeholder="Enter Name">
            <br>
            <input type="text" name="email" placeholder="Enter Email">
            <br>
            <input type="submit" name="signup" value="DO SIGNUP">
        </form>
    </body>
</html>

PHP Code

<?php
if (isset($_POST['signup'])) {
    $name   = $_POST['name'];
    $email  = $_POST['email'];
    $chars  = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $password = substr(str_shuffle($chars), 0, 8);
    mysqli_query($con,"insert into users (name,email,password) values('$name','$email','$password')");
    echo "Your Password Is : " . $password;
}
?>

0 Comments


Html code work in comment box


Related Post