|
 |
|
กดปุ่ม สมัครสาชิกแล้วปุ่มไม่ทำงานค่ะ ช่วยหา error ให้หน่อยค่ะ |
|
 |
|
|
 |
 |
|
อันนี้ form .js ค่ะ
Code (PHP)
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Mozilla, Safari ...
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //IE
} else {
alert("Your browser doesn't support the XmlHttpRequest object.");
}
}
var receiveReq = getXmlHttpRequestObject();
function checkpass(pwd, rpwd) {
if (pwd!=rpwd) {
document.getElementById("msg").innerHTML = '<font color=red>รหัสผ่านไม่ตรงกัน</font>';
document.form1.repassword.focus();
document.getElementById('txtCaptcha').disabled = true;
document.getElementById('btnSubmit').disabled = true;
} else {
document.getElementById("msg").innerHTML = '';
document.getElementById('txtCaptcha').disabled = false
document.getElementById('btnSubmit').disabled = false;
}
}
function makeRequest(url, param) {
if (receiveReq.readyState == 5 || receiveReq.readyState == 0) {
receiveReq.open("POST", url, true);
receiveReq.onreadystatechange = updatePage;
receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
receiveReq.setRequestHeader("Content-length", param.length);
receiveReq.setRequestHeader("Connection", "close");
receiveReq.send(param);
}
}
function updatePage() {
if (receiveReq.readyState == 5) {
document.getElementById('result').innerHTML = receiveReq.responseText;
document.getElementById("txtname").value = '';
document.getElementById("txtemail").value = '';
document.getElementById("txtlogin").value = '';
document.getElementById("password").value = '';
document.getElementById("repassword").value = '';
document.getElementById("txtpos").value = '';
document.getElementById('txtCaptcha').value = '';
img = document.getElementById('imgCaptcha');
img.src = 'redcaptcha.php?' + Math.random();
}
}
function refreshCap() {
img = document.getElementById('imgCaptcha');
img.src = 'redcaptcha.php?' + Math.random();
}
function check_data(nm, email, login, pwd, pos, cap, Mode) {
var cancle=false;
if (nm.length==0) {
alert('กรุณาป้อนชื่อด้วย');
document.form1.txtname.focus();
cancle=true;
} else
if (email.length==0) {
alert('กรุณาป้อนอีเมลด้วย');
document.form1.txtemail.focus();
cancle=true;
} else
if (login.length==0) {
alert('กรุณาป้อน login ด้วย');
document.form1.txtlogin.focus();
cancle=true;
} else
if (pwd.length==0) {
alert('กรุณาป้อน password ด้วย');
document.form1.password.focus();
cancle=true;
} else
if (pos.length==0) {
alert('กรุณาป้อน ตำแหน่ง ด้วย');
document.form1.txtpos.focus();
cancle=true;
} else
if (cap.length==0) {
alert('กรุณากรอกตัวอักขระสีแดงที่เห็นในภาพก่อน') + Mode;
document.form1.txtCaptcha.focus();
cancle=true;
}
if (cancle==false) {
var url = 'addmember.php';
var postStr = "tName=" + encodeURI( document.getElementById("txtname").value ) +
"&tEmail=" + encodeURI( document.getElementById("txtemail").value ) +
"&tLogin=" + encodeURI( document.getElementById("txtlogin").value ) +
"&tPwd=" + encodeURI( document.getElementById("password").value )+ "&tposition=" + encodeURI( document.getElementById("txtpos").value ) +
"&tCaptcha=" + encodeURI( document.getElementById("txtCaptcha").value )+
"&action=" + Mode ;
makeRequest(url, postStr);
}
return false;
}
|
 |
 |
 |
 |
Date :
2013-02-06 21:50:12 |
By :
yam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
และอันนี้เป็น form addmember ค่ะ
Code (PHP)
<?php
session_start();
include "include/config.php";
$strName = $_POST["tName"];
$strEmail= $_POST['tEmail'];
$strLogin = $_POST['tLogin'];
$strPwd = $_POST['tPwd'];
$strpos = $_POST['tposition'];
$strCaptcha=$_POST['tCaptcha'];
$strMode = $_POST["action"];
if ($strMode=="ADD") {
if($_SESSION["security_code"]==$strCaptcha){
$sql = "INSERT INTO tb_member VALUES ('$strName','$strLogin', '$strPwd','$strpos',$strEmail')";
$result = @mysql_query($sql) or die(mysql_error());
if($result) {
echo "<font color=#009900>บันทึกข้อมูลเรียบร้อยแล้ว</font><br><a href=\"javascript:window.close();\">หน้าต่างนี้</a>";
} else {
echo "<font color=#FF0000>ไม่สามารถบันทึกข้อมูลได้</font>";
}
} else {
echo "<font color=#FF0000>คุณไม่ผ่านการตรวจสอบ <br>กรุณาลองใหม่อีกครั้ง</font>";
}
}
if ($strMode=="EDIT") {
if($_SESSION["security_code"]==$strCaptcha){
$sql = "UPDATE tb_member SET member_name='$strName', member_password='$strPwd',member_email='$strEmail',member_pos='$strpos' WHERE member_name='$strLogin'";
$result = @mysql_query($sql) or die(mysql_error());
if($result) {
echo "<font color=#009900>แก้ไขข้อมูลเรียบร้อยแล้ว</font><br><a href=\"javascript:window.close();\">หน้าต่างนี้</a>";
} else {
echo "<font color=#FF0000>ไม่สามารถแก้ไขข้อมูลได้</font>";
}
} else {
echo "<font color=#FF0000>คุณไม่ผ่านการตรวจสอบ <br>กรุณาลองใหม่อีกครั้ง</font>";
}
}
mysql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2013-02-06 21:51:18 |
By :
yam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่าน Ajax Tutorial : สอน Ajax เขียน Ajax เรียน Ajax สุดยอดการใช้งาน Ajax อย่างง่าย
|
 |
 |
 |
 |
Date :
2013-02-07 09:20:42 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|