|
 |
|
ไม่ทราบการทำการสุ่มตัวเลขก่อนโพสต์ข้อความ คือผมกะลังทำ เว็บบอร์ดครับ ไม่ทราบเค้าทำกันยังไงครับ |
|
 |
|
|
 |
 |
|
แล้วแต่เทคนิคของแต่ละคนว่าจะทำให้เป็นรูปภาพหรือข้อความอ่านะ ลองทำดูแบบง่ายๆก็ประมาณว่า
ใช้ฟังก์ชั่น rand() ใน php อ่าครับ + javascript นิดหน่อยก็ใช้ได้แล้วเช่น
Code (PHP)
<?
$a=rand(0,9);
$b=rand(0,9);
$c=rand(0,9);
$d=rand(0,9);
$e=rand(0,9);
$ans=$a.$b.$c.$d.$e;
?>
<form id="test" action="page2.php" method="post" onsubmit="return check_datas('<?=$ans;?>','กรุณากรอกหรัสโพสให้ถูกต้องด้วยครับ');">
<div style="float:left;"><input type='text' id='security_code' name='security_code'></div> <div style="float:left;"><?=$ans;?></div>
<div><input type="submit" name="submit" value="submit"></div>
</form>
<script type="text/javascript" language="javascript">
function check_datas(ans,errText){
if(document.getElementById("security_code").value.length<5){ //ตรวจสอบว่าได้กรอกรหัสโพสแล้วหรือยัง
document.getElementById("security_code").focus();
alert("A "+errText);
return false;
}else{
if(document.getElementById("security_code").value==ans){ //ตรวจสอบว่าถ้ากรอกรหัสโพสถูกต้องให้ทำงานต่อได้
return true;
}else{
document.getElementById("security_codes").focus(); //ถ้ากรอกรหัสโพสไม่ถูกต้องให้เซ็ตโฟกัสที่เท็กบอกแล้วแจ้งข้อผิดพลาด
alert("B "+errText);
return false;
}
}
}
</script >
ลองปรับใช้ดูนะครับพัฒนาให้ดีขึ้น *_*
|
 |
 |
 |
 |
Date :
2010-06-07 00:58:23 |
By :
chineji |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ พี่ ที่ให้ความรู้โดยไม่พี่งหวังอะไร ขอให้มีความสุข ทั้งเรื่องงาน ครอบครัวน่ะครับ
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2010-06-07 09:15:46 |
By :
oon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|