|
 |
|
ขอความช่วยเหลือเกี่ยวกับ การตรวจสอบฟอร์ม (PHP + AJAX) ด่วนเลยครับ |
|
 |
|
|
 |
 |
|
อันนี้คือตัว javascript ครับ
Code (JavaScript)
<script type="text/javascript">
var ajax = false;
if(window.XMLHttpRequest) {
ajax = new XMLHttpRequest();
if(ajax.overrideMineType) {
ajax.overrideMineType('text/html');
}
} else if(window.ActiveXObject) {
try {
ajax = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
try {
ajax = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {
}
}
}
function ajaxLoad(method, url, data, displayID) {
if(ajax == false) {
alert('Cannot create XMLHTTP instance');
return false;
}
ajax.open(method, url, true);
ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
ajax.setRequestHeader('Content-length', data.length);
ajax.setRequestHeader('Connection', 'close');
ajax.onreadystatechange = function() {
if(ajax.readyState == 3 && ajax.status == 200) {
ajaxCallback(displayID, ajax.responseText);
}
if(ajax.readyState == 4 && ajax.status == 200) {
ajaxCallback(displayID, ajax.responseText);
}
}
ajax.send(data);
}
function ajaxCallback(displayID, responseText) {
var el = document.getElementByID(displayID); //---> มีปัญหาที่นี่
el.innerHTML = responseText;
}
function checkExpression(data, check, displayID) {
var url = 'register-check-expression.php?ihash=' + Math.random();
var data = 'email=' + encodeURI(data) + '&check=' + check;
ajaxLoad('post', url, data, displayID);
}
</script>
ส่วนอันนี้ php
Code (PHP)
<?php
include("common.php");
$data = $_POST["data"];
$check = $_POST["check"];
if($check == "username") {
$pattern = "^[a-z0-9_]{5, 15}$";
} else if($check == "email") {
$pattern = "[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2, 4})$";
/*if(trim($data) == "") {
//echo "<img src=\"images/false.png\" width=\"24\" height=\"24\" align=\"absmiddle\" />";
exit();
}
$strSQL = "SELECT * FROM tbl_or_members WHERE email = '" . $data . "'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
if($objResult) {
echo "<img src=\"images/false.png\" width=\"24\" height=\"24\" align=\"absmiddle\" />";
} else {
echo "<img src=\"images/true.png\" width=\"24\" height=\"24\" align=\"absmiddle\" />";
}*/
}
if(!eregi($pattern, $data)) {
//echo "<img src=\"images/false.png\" width=\"24\" height=\"24\" align=\"absmiddle\" />";
echo "false";
} else {
//echo "<img src=\"images/true.png\" width=\"24\" height=\"24\" align=\"absmiddle\" />";
echo "true";
}
?>
คือตอนนี้มันมีปัญหาในบรรทัด ที่มาร์คไว้ครับ โดยแจ้ง error ว่า Object doesn't support this property or method สงสัยว่าจะแกไขยังไงครับ
Tag : PHP, MySQL, JavaScript, Ajax

|
ประวัติการแก้ไข 2011-10-15 17:07:23
|
 |
 |
 |
 |
Date :
2011-10-15 13:10:55 |
By :
xirritate |
View :
975 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-10-15 14:00:39 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แฮะ ๆ ได้ละครับ เพราะความสะเพร่าของตัวเองชัด ๆ เลย อายจัง
Code (JavaScript)
var el = document.getElementByID(displayID); //---> มีปัญหาที่นี่
ต้องเป็น
Code (JavaScript)
var el = document.getElementById(displayID); //---> มีปัญหาที่นี่
|
 |
 |
 |
 |
Date :
2011-10-16 12:20:59 |
By :
xirritate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|