|
|
|
ถามเรื่องการทำตัวป้องกัน แสปม ค่ัะมัน error มันขึ้นมาว่า กรุณาใส่รหัสภาพด้วยค่ะ |
|
|
|
|
|
|
|
Code (PHP)
session_start();
require_once("config.inc/connect.php");
$im_txtcode = $_REQUEST["txtCode"];
$im_captcha = $_SESSION["captcha"];
if ($im_txtcode <> $im_captcha) {
print "<a href=# onclick='history.back()'><br><br><b><u>กรุณาใส่รหัสภาพด้วยค่ะ</u></b></a>";
unset($_SESSION["captcha"]);
die();
}else if (!empty($id) && !empty($txt_dedail) && !empty($txt_name)) {
$date=date("m-d-Y",time());
$query="insert into board_ans(
bq_id,
ba_detail,
ba_name,
ba_email,
ba_date
) values (
'$id',
'$txt_dedail',
'$txt_name',
'$txt_email',
'$date'
)";
if(mysql_query($query)){
print"<script language='JavaScript'>";
print"alert('ตอบกระทู้เรียบร้อยแล้วค่ะ');";
print"</script>";
print "<meta http-equiv='refresh' content='0;url=board.view.php?id=$id' />";
}else{
print "<a href=# onclick='history.back()'><br><br><b><u>ไม่สามารถ ตอบกระทู้ได้</u></b></a>";
}
}else{
print "<a href=# onclick='history.back()'><br><br><b><u>ไม่สามารถ ตอบกระทู้ได้</u></b></a>";
}
Tag : PHP, MySQL, CakePHP
|
|
|
|
|
|
Date :
2011-09-24 16:20:23 |
By :
mainland |
View :
811 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
form add ค่ะ ประมาณบรรทัดที่ 178
ตัวกรอกอยู่ประมาณบรรทัดที่ 228 ค่ะ
Code (PHP)
<?php
session_start();
require_once('include/top.inc.php');
function DateThai($strDate){
if($strDate){
$arrDate = explode("-",$strDate);
$timStmp = mktime(0,0,0,$arrDate[0],$arrDate[1],$arrDate[2]);
$strYear = date("Y",$timStmp)+543;
$strMonth = date("n",$timStmp);
$strDay = date("j",$timStmp);
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai = $strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear";
}else{
return "dd mm yyyy";
}
}
?>
<!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>
<?php require_once("include/head.inc.php"); ?>
<style type="text/css">
<!--
.style2 {color: #000000; font-size: 12px; }
.style6 {
color: #333333;
font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style7 {font-size: 10px}
.style8 {font-size: 10}
.style10 {
font-size: 10;
color: #868686;
font-weight: bold;
}
.style11 {color: #FF0000}
.style13 {
font-size: 10px;
color: #868686;
font-weight: bold;
}
.style14 {
color: #868686;
font-weight: bold;
}
.style31 {color: #999999}
.style35 {
font-size: 12px;
color: #333333;
}
.style36 {color: #666666}
.style38 {color: #333333; font-size: 12px; }
.style40 {color: #CCCCCC; font-size: 12px; }
.style41 {color: #666666; font-size: 12px; }
.style42 {color: #333333}
body {
background-color: #FFFFFF;
background-image: url();
}
-->
</style>
</head>
<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<?php require_once("include/header.inc.php"); ?>
<table width="930" align="center" cellpadding="0" cellspacing="0" background="image/body.png">
<tr>
<td width="270" align="center" valign="top"><?php require_once("include/left.inc.php"); ?></td>
<td valign="top">
<table border="0" align="center">
<tr>
<td><p> </p>
<table width="450" align="center">
<tr>
<td colspan="3"><img src="image/L3.png" width="479" height="26" /></td>
</tr>
<?php
$sqlBq = "select * from board_que where bq_id=$id";
$queryBq = mysql_query($sqlBq);
$rsBq= mysql_fetch_array($queryBq);
if(!$rsBq['bq_date']==""){
$dateThai=DateThai($rsBq['bq_date']);
}else{
$dateThai="";
}
?>
<tr>
<td width="88"><p class="style2">
<span class="style36">
<?=$rsBq['bq_name'];?>
</span></p>
<p class="style41">
<span class="style31">
<?=$dateThai;?>
</span></p>
<p class="style2">
<span class="style31">
<?=$rsBq['bq_email'];?>
</span> </p></td>
<td width="20" style="background-image:url(image/L4.png); background-repeat:repeat;"></td>
<td width="363" valign="top"><p class="style2">
<span class="style36">
<?=$rsBq['bq_detail'];?>
</span></p>
<p class="style2 style36"> </p>
<p class="style2 style36"> </p></td>
</tr>
<tr>
<td colspan="3"><p><img src="image/L5.png" width="480" height="4" /></p> </td>
</tr>
</table>
<p> </p>
</td>
</tr>
<tr>
<td><table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<?php
$sqlAns = "select * from board_ans order by bq_id asc";
$queryAns = mysql_query($sqlAns);
while ($rsAns= mysql_fetch_array($queryAns)){
$i++;
if(!$rsAns['ba_date']==""){
$dateThai=DateThai($rsAns['ba_date']);
}else{
$dateThai="";
}
?>
<tr>
<td width="90" align="left" valign="top" bgcolor="#CCCCCC" class="style36"><p class="style2">
<span class="style2">
<span class="style36">
<span class="style31">
<span class="style36">
<span class="style42">
<?=$rsAns['ba_name'];?>
</span></span></span></span></span></p>
<p class="style38 style36">
<span class="style35">
<span class="style36">
<?=$dateThai;?>
</span></span></p>
<p class="style40">
<span class="style38 style36">
<?=$rsAns['ba_email'];?>
</span> </p></td>
<td width="20" bgcolor="#CCCCCC" style="background-image:url(image/L4.png); background-repeat:repeat;"></td>
<td width="335" valign="top" bgcolor="#CCCCCC"><p>
<span class="style42">
<?=$rsAns['ba_detail'];?>
</span></p>
<p class="style6"> </p></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" class="style36"><p><img src="image/L5.png" width="400" height="4" /></p>
</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" class="style36"><p> </p>
<p> </p></td>
</tr>
<?php } ?>
</table>
<p> </p>
<p> </p>
<p> </p>
</td>
</tr>
<tr>
<td>
<?php
function captcha($len) {
srand((double)microtime()*10000000);
// ใส่อักษรที่ต้องการให้มีแสดงเวลาสุ่มออกมา
$chars="123456789";
$ret_str="";
$num=strlen($chars);
for($i=0;$i<$len;$i++)
$ret_str.= $chars[rand()%$num];
return $ret_str;
}
// คุณสามารถแก้ไขจำนวนตัวอักษรได้
$_SESSION['captcha'] = captcha(4);
?>
<form name="form" id="form" action="board.reply.save.php" method="post" enctype="multipart/form-data">
<table width="500" align="center">
<tr>
<td width="79" align="right"> </td>
<td width="409"><img src="image/L2.png" width="320" height="26" /></td>
</tr>
<tr>
<td width="79" align="right"> </td>
<td><span class="style7"><span class="style8"><span class="style7"><span class="style14">NAME</span><font color="#FF0000">*</font></span></span></span></td>
</tr>
<tr>
<td width="79" align="right"> </td>
<td><input name="txt_name" type="text" class="dpDayHighlightTD" id="txt_name" size="50"/></td>
</tr>
<tr>
<td width="79" align="right"> </td>
<td><span class="style13">E-MAIL</span></td>
</tr>
<tr>
<td width="79" align="right"></td>
<td><input name="txt_email" type="text" class="dpDayHighlightTD" id="txt_email" size="50" /></td>
</tr>
<tr>
<td width="79" align="right"></td>
<td><span class="style7"><span class="style10">MESSAGE<span class="style11">*</span></span></span></td>
</tr>
<tr>
<td width="79" align="right"> </td>
<td><textarea name="txt_dedail" cols="50" rows="5" class="dpDayHighlightTD" id="txt_dedail"></textarea></td>
</tr>
<tr>
<td colspan="2">
<p align="center"> </p> </td>
</tr>
<tr>
<td colspan="2" align="center">
<img src="image.php?code=<?=$_SESSION['captcha'];?>">
<input name="txtCode" type="text" size="4">
<input name="id" type="hidden" id="id" value="<?=$id; ?>" />
<input name="submit" type="submit" class="dpTable" id="submit" value="POST" />
<input name="reset" type="reset" class="dpTable" value="RESET" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
|
|
|
|
|
Date :
2011-09-24 16:26:36 |
By :
mainland |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณค่ะ ^^
|
|
|
|
|
Date :
2011-09-24 23:08:09 |
By :
mainland |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|