How to develop php script for forget password

Here we are developing code of how to develop php script for forget password. this is very simple and easy script for forget password in php.
you just have need some knowledge of php, mysql and some basic php applications such as login script and user registration and some mysql queries.

Lets we Start Php Code for Forget Password Script.
First we have need to create connection file connect to database.

/** The name of the database */
define('DB_NAME', 'phpkidadb');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', 'localhost');

mysqli_select_db($con, DB_NAME);

After created connection file we have need create php cript for forget password.
so here we will check form is submit or not if form is submit, then we will check enter email id by user is exist in user table of database, if email id exist so execute code of send password on email and show message to user. and if email id not exist in this case show error message to user.

PHP Code For Forget Password

 $pres=mysqli_query($con, "select email, password from users where email='$email'");
 $to = $email;

// subject
$subject = ' Reset Your Password ';

// message
$message = '
<title> Forget Password Script In PHP - PHPKIDA </title>


// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: Forget Password <>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

echo "Your Password Sent On Your Email Id, Check and login !";
 else{echo "Email Id Does Not Match ! Please Try Again And Check Your Email Id.";}

HTML Code For Form

 <form method="post">
 <input name="email" type="text" placeholder="Enter Your Email Id" required>
 <input type="submit" value="Reset Password" name="fpass">

I Hope You Like This Tutorial. If You Have Any Question Please Leave comment we will be focus on. Thank For Visit.

Leave a Reply

Related Posts: You may like

How to remove whitespace from string using php

Remove All Special Characters From String PHP

Redirecting HTTP to HTTPS with PHP

Convert Base64 string to an image file


Crypto Currency

PHPKIDA provides free online the best real-time crypto market price, news, predictions, index with graphs & historical data for 2000+ coins including bitcoin, ethereum, & altcoins from major cryptocurrency exchanges.

Visite Tool

Icon Generator

PHPKIDA provides free online icon generator. Our icon generator help you to edit, modify, resize and customize icon for your website and applications. Convert to a shap you like add icon border, you can change icon border color, border size, background color, icon shadow, icons color, icon size in your own way and save it as a png image.

Visite Tool

Youtube Video Downloader

PHPKIDA provides Free online YouTube video downloader to download YouTube videos quickly in MP4, 3GP, and more. Search your video and free fast download youtube videos.

Visite Tool

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.