สอบถามเรื่อง รีเซ็ตรหัสผ่านใหม่ หน่อยครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบถามเรื่อง รีเซ็ตรหัสผ่านใหม่ หน่อยครับ

สอบถามเรื่อง รีเซ็ตรหัสผ่านใหม่ หน่อยครับ
จากตัวอย่างนี้

https://www.ninenik.com/การรีเซ็ตรหัสผ่านใหม่_กรณีเข้ารหัสข้อมูล_ตอนที่_2-605.html

ผมลองทำตามแล้ว up ขึ้น host จริงพอใส่ตัว email แล้วกด submit แล้วหน้ามันว่างไปเลย ไม่ทราบว่าต้องไป set ค่าอะไรใน class.phpmailer.php เพิ่มเติมหรือเปล่าครับ


Pusirinon 110.170.246.xxx 06-10-2015 10:11:44

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ไม่น่าต้อง set อะไร แต่ต้องลองเช็คดูว่าฟังก์ช่ั่น mail บน host เขาเปิดให้ทำงานไหม
หรือดูส่วนอื่นๆ ประกอบ


ninenik 180.183.142.xxx 06-10-2015
 ความคิดเห็นที่ 2
ขอถามต่อจากเมื่อวานได้ไหมครับ พอดี ลองเปลี่ยน code แล้วก็ใช้ได้ แต่ติดปัญหาตรงที่พอมี mail ส่งกลับมาเป็น link ให้เรากด และเด้งต่อไปหน้าที่ให้ใส่ password ใหม่มันมี error แต่ไม่ทราบว่าจะต้องแก้ตรงไหนครับ

เมล์ลิ้งค์ที่ส่งมา activepassword.php

<?php
include "config.php"; // database connection details stored here
//////////////////////////////
$ak=$_GET['ak'];
$username=$_GET['username'];
?>
<link rel="stylesheet" href="css/jquery.motionCaptcha.0.2.css"/>	
<link rel="stylesheet" href="css/motionCaptcha.demo.css"/>	
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script src="js/jquery.placeholder.1.1.1.min.js" type="text/javascript"></script>
<script language="javascript">
function fncSubmit()
{

	if(document.form1.password.value != document.form1.password2.value)
	{
		alert('รหัสผ่านใหม่ไม่ตรงกัน');
		document.form1.password2.focus();		
		return false;
	}	

	document.form1.submit();
}
</script>
<?php
//$userid=mysql_real_escape_string($userid);
//$ak=mysql_real_escape_string($ak);


$tm=time()-86400; // Durationg within which the key is valid is 86400 sec. 

$sql=$dbo->prepare("SELECT username FROM plus_key WHERE pkey=:ak and username=:username and time > '$tm' and status='pending'");
$sql->bindParam(':username',$username,PDO::PARAM_STR, 100);
$sql->bindParam(':ak',$ak,PDO::PARAM_STR, 32);
$sql->execute();
$no=$sql->rowCount();
echo " No of records = ".$no; 

if($no <>1){
echo "<center><font face='Verdana' size='4' color=red><br/><b>ยืนยันการใช้งานไม่ถูกต้อง</b></font> "; 
exit;
}
?>
<div class="page">
	<div class="page_header clearfix page_margin_top">
		<div class="page_header_left">
			<h1 class="page_title">รหัสผ่านใหม่ </h1>
		</div>
	</div>
	<div class="page_layout clearfix">
		<div class="divider_block clearfix">
			<hr class="divider first">
			<hr class="divider subheader_arrow">
			<hr class="divider last">
		</div>
		<div class="row page_margin_top">
			<div class="column column_1_3">
				<h4 class="box_header">&nbsp;</h4>
			</div>
			<div class="column column_1_3">
					<h4 class="box_header">กรอกรหัสผ่านใหม่</h4>
					<form role="form" class="margin_top_15" name="form1" method="post" action="activepasswordck.php" enctype="multipart/form-data" OnSubmit="return fncSubmit();">
					<input type="hidden" name="todo" value="new-password">
					<input type="hidden" name="ak" value="$ak">
					<input type="hidden" name="username" value="$username">
						<fieldset class="box_input margin_top_10">
							<div class="block">
								<input class="text_input" name="password" id="password" type="password" placeholder="กรอกรหัสผ่านใหม่ " autocomplete="off" required>
							</div>
						</fieldset>
						<fieldset class="box_input margin_top_10">
							<div class="block">
								<input class="text_input" name="password2" id="password2" type="password" placeholder="ยืนยันรหัสผ่านใหม่" required>
							</div>
						</fieldset>
						<fieldset class="margin_top_10">
							<input type="submit" value="รีเซ็ตรหัสผ่าน" id="submit_resetpassword" name="submit_resetpassword" class="more active">
							<!-- <button type="submit" id="submit_resetpassword" value="รีเซ็ตรหัสผ่าน" name="submit_resetpassword" class="more active">รีเซ็ตรหัสผ่าน</button> -->
						</fieldset>
					</form>
			</div>
			<div class="column column_1_3">
				<h4 class="box_header">&nbsp;</h4>
			</div>
		</div>
	</div>
</div>

หน้าส่งข้อมูล activepasswordck.php

<?php
//***************************************
// This is downloaded from www.plus2net.com //
/// You can distribute this code with the link to www.plus2net.com ///
//  Please don't  remove the link to www.plus2net.com ///
// This is for your learning only not for commercial use. ///////
//The author is not responsible for any type of loss or problem or damage on using this script.//
/// You can use it at your own risk. /////
//*****************************************
//include "include/session.php";
include "config.php"; // database connection details stored here
 // database connection details stored here
//////////////////////////////
$ak=$_POST['ak'];
$username=$_POST['username'];
$todo=$_POST['todo'];
$password=$_POST['password'];
$password2=$_POST['password2'];

?>
<html>
<head>
<title>เปลี่ยน Password</title>
<meta HTTP-EQUIV="Refresh" CONTENT="3;URL=./?page=home" charset="utf-8">
<link rel="shortcut icon" href="stylesheet/img/devil-icon.png"> <!--Pemanggilan gambar favicon-->
<link rel="stylesheet" type="text/css" href="administrator/mos-css/mos-style.css"> <!--pemanggilan file css-->
</head>

<body>
<div id="errorForm">
<?php
//$userid=mysql_real_escape_string($userid);
//$ak=mysql_real_escape_string($ak);


$tm=time()-86400;


$sql=$dbo->prepare("SELECT username  FROM plus_key WHERE pkey=:ak and username=:username and time > '$tm' and status='pending'");
$sql->bindParam(':username',$username,PDO::PARAM_STR, 100);
$sql->bindParam(':ak',$ak,PDO::PARAM_STR, 32);
$sql->execute();
$no=$sql->rowCount();
echo " No of records = ".$no; 

if($no <>1){
echo "<center><font face='Verdana' size='4' color=red><br/><b>ยืนยันการใช้งานไม่ถูกต้อง </b></font> "; 
exit;
}

////////////////////// Show the change password form //////////////////

if(isset($todo) and $todo=="new-password"){
//$password=mysql_real_escape_string($password);

//Setting flags for checking
$status = "OK";
$msg="";

if($status<>"OK"){ 
echo "<font face='Verdana' size='2' color=red>$msg</font><br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}else{ // if all validations are passed.
$password=md5($password); // Encrypt the password before storing

// Update the new password now //
$count=$dbo->prepare("update member set password='$password' where username='$username' ");
$count->execute();
$no=$count->rowCount();
//echo " No of records = ".$no; 
if($no==1){

$tm=time();
// Update the key so it can't be used again. 
$count=$dbo->prepare("update plus_key set status='done' where pkey='$ak' and username='$username' and status='pending'");
$count->execute(); 

echo "<font face='Verdana' size='4' ><center>ขอบคุณครับ <br> รหัสผ่านของท่านถูกเปลี่ยนเรียบร้อย </font></center>";
}else{echo "<font face='Verdana' size='2' color=red><center>ขอโทษครับ <br> การเปลี่ยนรหัสผ่านไม่สำเร็จ กรุณาติดต่อผู้ดูแลระบบ</font></center>";
} // end of if plus_signup is updated with new password
} // end of if status <> 'OK'
}


?>
</div>
</body>

</html>
พอลองใส่ passwod ใหม่แล้วมัน  error หน้า activepasswordck.php ขึ้นว่า "ยืนยันการใช้งานไม่ถูกต้อง" และลอง echo ค่าออกมาค่าของ No of records = 0


pusirinon 110.170.246.xxx 07-10-2015 08:29






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ