|
 |
|
มีปัญหา เกี่ยวกับ code Ajax สำหรับ recheck password |
|
 |
|
|
 |
 |
|
แล้วเขียนแบบไหนหละครับ เอามาดูเลย
|
 |
 |
 |
 |
Date :
2010-04-15 22:21:16 |
By :
LindyFralin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเอามาเฉพาะ code ที่มีปัญหานะครับ
register.php
<script language="JavaScript">
function ReCheckPass() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'test_jv_pass.php';
var pmeters1 = "CheckPass=" + encodeURI( document.getElementById("pass_reg").value)+
"ReCheck=" + encodeURI( document.getElementById("pass_reg_re").value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters1.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters1);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan1").innerHTML = "..";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan1").innerHTML = HttPRequest.responseText;
}
}
}
</script>
test_jv_pass.php
Code (PHP)
<?php
$CheckPass = trim($_POST["CheckPass"]);
$ReCheck = trim($_POST["ReCheck"]);
if ($CheckPass = "") {
echo "CheckPass ว่าง" ; exit();
}
if ($ReCheck = "") {
echo "ReCheck ว่าง" ; exit();
}
if($CheckPass <> $ReCheck)
{
echo "<span class='style14'>Password ไม่เหมือนกัน กรุณาตรวจสอบอีกครั้ง</span>";
exit();
}
elseif ($CheckPass == $ReCheck) {
echo "<span class='style13'>Password correct</span>";
exit();
}
else {
echo "<span class='style14'>System Error</span>" ;
}
?>
|
 |
 |
 |
 |
Date :
2010-04-15 22:53:16 |
By :
nopasurada |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ตรง รบกวน ถึง ajax ครับผม
javascript เดิม ๆ ก็ทำได้แล้น
if(myform.password.value != myform.repassword.value){
document.getElementById("element").innerHTML = "รหัสไม่เท่ากัน";
}
ตรวจสอบ syntax อีกที ผมไม่ได้ตรวจสอบครับ แต่ใช้ javascript ก็ทำได้ครับ
|
 |
 |
 |
 |
Date :
2010-04-16 01:45:17 |
By :
LindyFralin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สวัสดีครับ
ผมก็ไม่เข้าใจเหมือนกันนะ ทำไม recheck password ต้องใช้ ajax ในเมื่อส่วนนึงคือ security ที่เกี่ยวกับความลับ ของแต่ละ user
หากเป็นการ check user เพื่อ register นั่นก็เพราะเพื่อความสะดวกสบาย
แนะนำให้ลองคุยกันก่อนที่จะ update หรือทำอะไรเพิ่ม ว่าอะไรคือ requirement และอะไรคือความจำเป็น ไม่งั้นถ้าทำตามใจอย่างเดียว อนาคตก็งานเข้าได้เหมือนกันครับ
|
 |
 |
 |
 |
Date :
2010-04-16 09:53:21 |
By :
winphp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณ LindyFralin มากเลยครับ ผมนั่งงงมาหลายวัน ได้แล้วครับ
ตอบคำถามคุณ win นะครับ
อ่อ ส่วนนี้คือผมต้องการแค่ให้ user ได้รู้ก่อน จะกด submit นะครับว่า password ถูกต้องไหม จะได้ไม่เสียเวลา
กลับมากรอกข้อมูลใหม่หาก ใส่ password ไม่ถูก
|
 |
 |
 |
 |
Date :
2010-04-16 12:03:24 |
By :
nopasurada |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|