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

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.


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

PHP Code

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;


Html code work in comment box

Related Post