We can create Forgot Password feature using PHP. PHP is a popular language Send Forgot password by mail or message in PHP.
You know about validate login forms with remember me and sign-out concepts using PHP.Get more knowledge about PHP from its official website: https://php.net/
Now see about how to send forgotten password to mail using php?. First your table contains users mail id. Just imagine this is your table:
Now first make a connection file named db.php
db.php
<?php $servername='localhost'; $username='root'; $password=''; $dbname = "password_recover"; $conn=mysqli_connect($servername,$username,$password,"$dbname"); if(!$conn){ die('Could not Connect My Sql:' .mysql_error()); } ?>
Now we will call this connection into our mail index file .
index.php
<?php session_start(); include_once 'db.php'; if(isset($_POST['submit'])) { $user_id = $_POST['user_id']; $result = mysqli_query($conn,"SELECT * FROM user_details where user_id='" . $_POST['user_id'] . "'"); $row = mysqli_fetch_assoc($result); $fetch_user_id=$row['user_id']; $email_id=$row['email_id']; $password=$row['password']; if($user_id==$fetch_user_id) { $to = $email_id; $subject = "Password"; $txt = "Your password is : $password."; $headers = "From: password@learncoders.com" . "\r\n" . "CC: receiver@example.com"; mail($to,$subject,$txt,$headers); } else{ echo 'invalid userid'; } } ?> <!DOCTYPE HTML> <html> <head> <style type="text/css"> input{ border:1px solid olive; border-radius:5px; } h1{ color:darkgreen; font-size:22px; text-align:center; } </style> </head> <body> <h1>Forgot Password<h1> <form action='' method='post'> <table cellspacing='5' align='center'> <tr><td>user id:</td><td><input type='text' name='user_id'/></td></tr> <tr><td></td><td><input type='submit' name='submit' value='Submit'/></td></tr> </table> </form> </body> </html>
Read our More Tutorials