Forget Password dengan PHP dan MySql

inc-db.php

<?php
mysql_connect('localhost','root','');
mysql_select_db('lukman_hakim');
?>

 

frm_forget_password.php

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="lolkittens" />

    <title>Untitled 2</title>
</head>

<body>
<?php
error_reporting(0);
if($_GET['action']=='gagal'){
     echo"password tidak terkirim ke email anda";
}
?>

<form method="post" action="password_check.php">
<table>
<tr><td>Email</td><td>:</td><td><input type="text" name="frm_email"/></td></tr>

<tr><td><input type="submit" value="Kirim"/></td></tr>
</table>
</form>


</body>
</html>

password_check.php


<?php
require_once('inc-db.php');
$var_email=$_POST['frm_email'];
$sql_check="SELECT * FROM tb_admin WHERE admin_email='".$var_email."'";
//echo $sql_check;
//exit;

$result=mysql_query($sql_check);
$rows=mysql_num_rows($result);
//echo $rows;
//exit;


if($rows > 0 ){
    $data=mysql_fetch_array($result);
    $kepada=$var_email;
    $dari="from : joker@edi091.hol.es";
    $subject="Tes Email";  //judul email
    $pesan="Halo Gan ".$data['admin_username'].", <br>

Seperti permintaan, password Agan telah direset. Berikut password barunya: <br>

Username: ".$data['admin_username']." <br>
Password: ".$data['admin_password']."

Agan bisa mengganti password ini. Jika ingin menggantinya, lakukan di pengaturan profil: http://www.kaskus.co.id/user/editprofile


Terima Kasih,
Developer Code - The Largest Indonesian Community ";
   // $pesan="Password anda  ".$data['admin_password']; //pesan
    mail($kepada,$subject,$pesan,$dari);  //fungsi untuk kirim email
    //if($kirim_email){
    echo"password berhasil terkirim ke email anda";
    }else{
   header('location: frm_forget_password.php?action=gagal');
}

?>


0 Response to "Forget Password dengan PHP dan MySql"

Posting Komentar