คือว่า ผม จะทำ การ check user ว่า user ซ้ำ หรือเปล่า
มีโค๊ด ดังนี้ ลองทำดูแล้ว มันไม่ยอม check ใน Firefox และ IE อ่ะครับ แต่ โครม ได้
Register.html
มีโค๊ด ดังนี้ ลองทำดูแล้ว มันไม่ยอม check ใน Firefox และ IE อ่ะครับ แต่ โครม ได้
Register.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<title>Untitled Document</title>
<script src="prototype.js" language="JavaScript" type="text/javascript">
</script>
<script language="javascript" type="text/javascript">
function checkUsername(Div){
var params = "username=" + document.getElementById("username").value;
var url = "checkuser.php";
var myAjax = new Ajax.Updater(Div,url, {method: "post", parameters: params});
}
<body>
<form id="register" name="register" method="post" action="check_register.php">
<br><br>
<label for="username">ชื่อผู้ใช้</label>
<input name="username" type="text" id="username" value="" maxlength="24" placeholder="กรอกชื่อผู้ใช้" onblur="checkUsername(checkuser)"/>
<spen id=checkuser><img src='images/false.png'></spen>
checkuser.php
<?
$username = $_POST['username'];
include("config.php");
$count_test = mysql_num_rows(mysql_query("SELECT * FROM $tbname WHERE username = '$username' "));
$lang = "^[a-zA-Z0-9][a-zA-Z0-9]*$";
if (!ereg($lang,$username)){
print "<img src='images/false.png'>";
} elseif ( (strlen($username)<8) || (strlen($username)>24) ) {
print "<img src='images/false.png'>";
} elseif ( $count_test != 0 ) {
print "<img src='images/false.png'>";}
else {
print "<img src='images/true.png'>";
}
mysql_close($objConnect);
?>
onblur="checkUsername('checkuser')"ลองดูนะครับ
เหตุผลก็เพราะ จากโค้ดที่ให้มา checkuser จะเป็นตัวแปร ไม่ใช่ข้อความ ดังนั้น ต้องใส่เครื่องหมาบคำพูดให้มัน มันถึงจะเป็น ข้อความครับ
ตอน นี้ ผม งง มากเลย ลองงมๆ ดู
อย่างที่ท่านบอกก็ได้ นะครับ
แล้วอีกอย่าง ผมลอง ไป ลบ
อย่างที่ท่านบอกก็ได้ นะครับ
แล้วอีกอย่าง ผมลอง ไป ลบ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
ให้เหลือแต่ <html> ก้ได้ เช่นกัน ครับ
ผมก็ไม่รู้เป็นที่อะไร แล้ว อีกอย่าง ie 8 ผมก็ไม่แสดงผล จาวาเลย ทั้งๆ ที่เปิดฟังชั่น securitu >> custom level แล้วนะครับ
ให้เหลือแต่ <html> ก้ได้ เช่นกัน ครับ
ผมก็ไม่รู้เป็นที่อะไร แล้ว อีกอย่าง ie 8 ผมก็ไม่แสดงผล จาวาเลย ทั้งๆ ที่เปิดฟังชั่น securitu >> custom level แล้วนะครับ
จริงๆแล้ว ถ้าสามารถใช้งานเว็บผมได้ปกติ Browser ก็ไม่น่าจะมีปัญหาอะไร
บนเว็บก็มีตัวอย่างตามแบบทที่ต้องการนะครับ ลองศึกษาดู
บนเว็บก็มีตัวอย่างตามแบบทที่ต้องการนะครับ ลองศึกษาดู