How to generate Random Password in PHP | Coding Tag

How to generate Random Password in PHP ?

0 3305

To store a Random Password into Database, the Syntax is: mt_rand(1000000, 2555555). For more information and how to use please check below complete code:

$connect=mysql_connect("servername","username","password") OR die ("connection failed");
$db=mysql_select_db("database_name", $connect);


//the following code will automatically generate a random password and will store into database.

$pass=mt_rand(1000000, 2555555);

$sql="INSERT INTO students(name,email,class,password) VALUES('$name','$email','$class','$pass')";
echo "New data is created." ;
echo "Error !!" ;

<form action="" method="post">

<input type="text" name="name" placeholder="Full Name">
<input type="email" name="email" placeholder="Enter your email-id">
<input type="text" name="class" placeholder="Enter class name">
<input type="submit" name="submit" value="Click Here">


Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments