Today, We want to share with you forgot password in php.In this post we will show you Change or reset password php code, hear for Change or reset password in php mysqli we will give you demo and example for implement.In this post, we will learn about password by mail or message in PHP with an example.
simple forgot password code in php
Contents
There are the Following The simple About send reset password link email ph Full Information With Example and source code.
As I will cover this Post with live Working example to develop Change or reset password in php, so the Change or reset password code in php with mail is used for this example is following below.
Step 1: connecting database
dbConfig.php
<?php $servername='localhost'; $username='root'; $password=''; $dbname = "pakainfo"; $conn=mysqli_connect($servername,$username,$password,"$dbname"); if(!$conn){ die('Could not Connect My Sql:' .mysql_error()); } ?>
Step 2: Forgot Password in PHP
index.php
<?php session_start(); include_once 'dbConfig.php'; if(isset($_POST['submit'])) { $member_id = $_POST['member_id']; $result = mysqli_query($conn,"SELECT * FROM member_details where member_id='" . $_POST['member_id'] . "'"); $data = mysqli_fetch_assoc($result); $fetch_member_id=$data['member_id']; $email_id=$data['email_id']; $password=$data['password']; if($member_id==$fetch_member_id) { $to = $email_id; $subject = "Password"; $txt = "Your password is : $password."; $headers = "From: [email protected]" . "\r\n" . "CC: [email protected]"; mail($to,$subject,$txt,$headers); } else{ echo 'invalid memberid'; } } ?> <!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>member id:</td><td><input type='text' name='member_id'/></td></tr> <tr><td></td><td><input type='submit' name='submit' value='Submit'/></td></tr> </table> </form> </body> </html>
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about forgot password in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.