 |
|
|
 |
 |
|
ทำฟร์อม forgetpassword.html
<HTML>
<HEAD><TITLE>Member ระบบสมาชิก</TITLE></HEAD>
<BODY>
<h1>:: Forget Password ::</h1>
<FORM METHOD="POST" ACTION="forgetpassword2.php">
กรอก Username ระบบจะส่งรหัสผ่านไปทางอีเมลของท่าน
<TABLE>
<TR>
<TD><B>Username :</B> </TD>
<TD><INPUT NAME="user_forget" TYPE="text"> <INPUT name="submit" TYPE="submit" VALUE="Submit">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
/////////////////////////////////////////////////
โค้ด forgetpassword2.php
<?
$user_forget=$_POST[user_forget];
if ($user_forget=="") {
echo "<h3>ERROR : กรุณากรอกข้อมูลให้ครบนะคะ<h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_forget' ";
$result=mysql_db_query($dbname,$sql);
$num=mysql_num_rows($result);
$record=mysql_fetch_array($result);
$to=$record[email];
$password=$record[password];
if($num<=0) {
echo "<h3>ERROR : Username นี้ไม่มีอยู่ในระบบสมาชิกค่ะ</h3>";
} else {
$subject = "แจ้งรหัสผ่านของระบบสมาชิก";
$message = "รหัสผ่านของ Username : $user_forget คือ: $password";
$headers = "From: Member ระบบสมาชิก";
if (mail($to, $subject, $message, $headers)) {
echo "<h3>ระบบได้ส่งรหัสผ่านไปทางอีเมลเรียบร้อยแล้วค่ะ</h3>";
} else {
echo "<h3>ไม่สามารถส่งรหัสผ่านไปทางอีเมลได้</h3>";
}
}
mysql_close();
?>
|
 |
 |
 |
 |
Date :
9 ต.ค. 2551 13:45:26 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดูครับ
$email=$_POST['email'];
$email=mysql_real_escape_string($email);
$status = "OK";
$msg="";
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
// ใส่ the error message by un commenting the above line
if (!stristr($email,"@") OR !stristr($email,".")) {
$msg="Your email address is not correct<BR>";
$status= "NOTOK";}
echo "<br><br>";
if($status=="OK"){ // validation passed now we will check the tables
$query="SELECT email,userid,password FROM plus_signup WHERE plus_signup.email = '$email'";
$st=mysql_query($query);
$recs=mysql_num_rows($st);
$row=mysql_fetch_object($st);
$em=$row->email;// email is stored to a variable
if ($recs == 0) { // No records returned, so no email address in our table
// let us show the error message
echo "<center><font face='Verdana' size='2' color=red><b>No Password</b><br> Sorry Your address is not there in our database . You can signup and login to use our site. <BR><BR><a href='signup.php'> Sign UP </a> </center>";
exit;}
// formating the mail posting
// headers here
$headers4="[email protected]"; // Change this address within quotes to your address
$headers.="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$headers .= "Errors-to: $headers4\n";
//$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers;
// for html mail un-comment the above line
// mail funciton will return true if it is successful
if(mail("$em","Your Request for login details","This is in response to your request for login detailst at site_name \n \nLogin ID: $row->userid \n Password: $row->password \n\n Thank You \n \n siteadmin","$headers")){echo "<center><font face='Verdana' size='2' ><b>THANK YOU</b> <br>Your password is posted to your emil address . Please check your mail after some time. </center>";}
else{// there is a system problem in sending mail
echo " <center><font face='Verdana' size='2' color=red >There is some system problem in sending login details to your address. Please contact site-admin. <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";}
}
else {// Validation failed so show the error message
echo "<center><font face='Verdana' size='2' color=red >$msg <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";}
|
 |
 |
 |
 |
Date :
9 ต.ค. 2551 15:25:20 |
By :
passevil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดีมากๆครับ
|
 |
 |
 |
 |
Date :
2010-01-26 20:00:16 |
By :
อาจารย์ Bobby |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
mysql_connect("localhost","root","root");
mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."'
OR Email = '".trim($_POST['txtEmail'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not Found Username or Email!";
}
else
{
echo "Your password send successful.<br>Send to mail : ".$objResult["Email"];
$strTo = $objResult["txtEmail"];
$strSubject = "Your Account information username and password.";
$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "From: [email protected]\nReply-To: [email protected]";
$strMessage = "";
$strMessage .= "Welcome : ".$objResult["Name"]."<br>";
$strMessage .= "Username : ".$objResult["Username"]."<br>";
$strMessage .= "Password : ".$objResult["Password"]."<br>";
$strMessage .= "=================================<br>";
$strMessage .= "ThaiCreate.Com<br>";
$flgSend = mail($strTo,$strSubject,$strMessage,$strHeader);
}
mysql_close();
?>
Go to : PHP Forgot Lost Password and Sending Password to Mail ทำ Form ลืมรหัสผ่าน ด้วย PHP กับ MySQL
|
 |
 |
 |
 |
Date :
2011-07-07 11:13:34 |
By :
thaicreate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆค่ะ
|
 |
 |
 |
 |
Date :
2011-07-28 10:29:34 |
By :
Anijang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
No. 4 By : thaicreate ผมลองแล้วนะมันไม่ได้ต้องแก้ $strTo = $objResult["txtEmail"]; เป็น $strTo = $_POST["txtEmail"]; ครับ และก็ได้เฉยเลย
Code (PHP)
<?
mysql_connect("localhost","root","root");
mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."'
OR Email = '".trim($_POST['txtEmail'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not Found Username or Email!";
}
else
{
echo "Your password send successful.<br>Send to mail : ".$objResult["Email"];
$strTo = $_POST["txtEmail"];
$strSubject = "Your Account information username and password.";
$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "From: [email protected]\nReply-To: [email protected]";
$strMessage = "";
$strMessage .= "Welcome : ".$objResult["Name"]."<br>";
$strMessage .= "Username : ".$objResult["Username"]."<br>";
$strMessage .= "Password : ".$objResult["Password"]."<br>";
$strMessage .= "=================================<br>";
$strMessage .= "ThaiCreate.Com<br>";
$flgSend = mail($strTo,$strSubject,$strMessage,$strHeader);
}
mysql_close();
?>
|
 |
 |
 |
 |
Date :
2012-03-10 01:30:57 |
By :
tong18315 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error นี้ในบทความมีบอกไว้ครับ
|
 |
 |
 |
 |
Date :
2012-09-17 06:36:30 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Your password send successful.
Send to mail : [email protected]
มันขึ้นแบบนี้ค่ะ พอไปดูในเมล์แล้วไม่มีเมล์ส่งเข้ามาเลย
|
 |
 |
 |
 |
Date :
2013-01-05 22:09:42 |
By :
tiffy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยหน่อยน่ะค่ะ TT^TT อยากให้มันส่งเข้ามาในเมล์ให้ได้นั่งทำมาเป็นวันแล้วค่ะ
ขอบคุณล่วงหน้าค่ะ
|
 |
 |
 |
 |
Date :
2013-01-05 22:18:23 |
By :
tiffy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
PHP Forgot Lost Password and Sending Password to Mail ..
|
 |
 |
 |
 |
Date :
2015-01-25 16:26:03 |
By :
fff |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (SQL)
CREATE TABLE "forgetpass" (
"id" int(11) NOT NULL,
"email" varchar(100) NOT NULL,
"dateregist" varchar(50) NOT NULL,
"status" varchar(20) NOT NULL,
PRIMARY KEY ("id")
);
2. สร้างหน้าฟอร์ม php 2 หน้าน่ะคะ คือ ForgetPass.php และ ForgetPassSend.php ดังนี้
//Code php หน้า ForgetPass.php
<td width="482">
<script language="JavaScript">
function checkEmail()
{
var e1 = document.webFormEmail.email.value;
if( e1.length ==0)
{
alert("กรุณาใส่ Email Address ด้วยค่ะ");
document.webFormEmail.email.focus();
return false;
}
else
return true;
}
function chkEmail(){
if(document.webFormEmail.email.value!=""){
if (document.webFormEmail.email.value.match(/.+@.+\..+/) == null) {
alert("กรุณากรอก E-Mail ให้ถูกต้อง");
document.webFormEmail.email.focus();
}
}
}
</script> <table width="581" border="0" cellspacing="1" cellpadding="1">
<form method="post" action="ForgetPassSend.php" name="webFormEmail" onSubmit="return checkEmail()">
<tr>
<td colspan="2"><br> <strong>**
กรณีลืมรหัสผ่าน? **<br>
</strong> ระบบจะทำการ Reset Password
ให้ทางสมาชิกใหม่ เมื่อคำร้องถูกส่งเรียบร้อยแล้ว</td>
</tr>
<tr>
<td width="170"><div align="right">Email
Address :</div></td>
<td width="404"><input name="email" type="text" class="inputxx" id="email" size=50 / onblur="chkEmail()"></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input name="submit" type="submit" class="submitxx" value="ยืนยันการขอรหัสผ่านทางอีเมล์"></td>
</tr>
</form>
</table>
<br> <br> <br> </td>
Code php หน้า ForgetPassSend.php
<?
@session_start();
ob_start();
$usermem = $_SESSION["usermem"];
require_once "include/connectdb.php";
$sqlforget="select * from member where email='$_POST[email]'";
$db_query=mysql_db_query($db,$sqlforget);
$resultfg=mysql_fetch_array($db_query);
$usermember=$resultfg[usermem];
$passmember=$resultfg[passmem];
$num_rows=mysql_num_rows($db_query);
if($num_rows<1)
{
$head1 = "Invalid Email...";
$sub1 = "ไม่พบ Email ที่คุณกรอก<br>กรุณาตรวจสอบอีกครั้ง<br><a href=ForgetPass.php>ย้อนกลับ</a>";
}else{
$head1 = "Success...";
$sub1 = "คำร้องของคุณได้ส่งไปยังผู้ดูแลระบบเพื่อทำการ Reset Password ให้ใหม่<br>จะดำเนินการแจ้งไปยังอีเมล์ของคุณในขั้นตอนต่อไป..ขอบคุณค่ะ";
mysql_query("INSERT INTO forgetpass (id,email,dateregist,status) values('', '$_POST[email]','$e_date $etime','00000')") or die ("Cannot Add Database");
}
?>
<html>
<head>
<title><? echo "$headtxt_web"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/instyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#FFFFFF"><div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="201"> </td>
<td width="482"><div align="center"><br>
<br>
<br>
<? echo "<b>$head1</b><br>$sub1"; ?>
</div></td>
<td width="244"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td> </td>
</tr>
</table>
<br> <br> <br> </td>
</tr>
</table>
</div></td>
<td><img src="images/spacer.gif" width="1" height="25" border="0" alt=""></td>
</tr>
<tr>
<td colspan="5"><div align="center"><? echo "$buttomtxt_web"; ?></div></td>
<td><img src="images/spacer.gif" width="1" height="40" border="0" alt=""></td>
</tr>
</table>
</body>
</html>
ลองเอาไปใช้ดูนะคะ
|
 |
 |
 |
 |
Date :
2015-01-26 06:06:30 |
By :
รู้สึกดีจัง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|