Wednesday, 9 December 2015

how to Recover password script in php

<?php
session_start();
include('include/config.php');
include('include/header.php');
include_once("log_usr/cl_ne/classes/class.messages.php") ;
//include_once("classes/db_table_details.php");
include_once("log_usr/cl_ne/classes/functions.php");
include_once("log_usr/cl_ne/classes/class.validation.php");

    if (isset($_POST['username'])){

        $username = $_POST['username'];

        $query="select * from book_user_reg where book_user_email='$username'";

        $result   = mysqli_query($con,$query);

        $count=mysqli_num_rows($result);

        // If the count is equal to one, we will send message other wise display an error message.

        if($count==1)

        {

            $rows=mysqli_fetch_array($result);

            $pass  =  $rows['book_user_pwd'];//FETCHING PASS

            //echo "your pass is ::".($pass)."";

            $to = $rows['book_user_email'];

            //echo "your email is ::".$email;

            //Details for sending E-mail

            $from = "Coding Cyber";

            $url = "http://writeup.ecoveretail.com/";

            $body  =  "Coding Cyber password recovery Script

            -----------------------------------------------

            Url : $url;

            email Details is : $to;

            Here is your password  : $pass;

            Sincerely,

            Coding Cyber";

            $from = "manjeet@ecovesolutions.com";

            $subject = "CodingCyber Password recovered";

            $headers1 = "From: $from\n";

            $headers1 .= "Content-type: text/html;charset=iso-8859-1\r\n";

            $headers1 .= "X-Priority: 1\r\n";

            $headers1 .= "X-MSMail-Priority: High\r\n";

            $headers1 .= "X-Mailer: Just My Server\r\n";

            $sentmail = mail ( $to, $subject, $body, $headers1 );

        } else {

        if ($_POST ['email'] != "") {

        echo "<span style='color: #ff0000;'> Not found your email in our database</span>";

            }

            }

        //If the message is sent successfully, display sucess message otherwise display an error message.

        if($sentmail==1)

        {

            echo "<span style='color: #ff0000;'> Your Password Has Been Sent To Your Email Address.</span>";

        }

            else

            {

            if($_POST['email']!="")

            echo "<span style='color: #ff0000;'> Cannot send password to your e-mail address.Problem with sending mail...</span>";

        }

    }

    ?>
<html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Home: Webpage</title>

    </head>

    <body>
<div class="container">
    <form action="" method="post">

            <label> Enter your User ID : </label>

            <input id="username" type="text" name="username" />

            <input id="button" type="submit" name="button" value="Submit" />

        </form>
</div>
    </body>

    </html>
<?php include('include/footer.php'); ?>

No comments:

Post a Comment