读书人

写下敏感词

发布时间: 2012-09-01 09:33:03 作者: rapoo

写入敏感词
<script language="JavaScript">
function check(myform){
if(myform.txt_word.value==""){
alert("敏感词不能为空");myform.txt_word.focus();return false;
}
}
</script>

<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>

</tr>
<tr>

<td width="757" align="center" valign="top" bgcolor="#FFFFFF"><table width="100%" height="59" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="../images/addword.jpg"> </td>
</tr>
</table>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="613" height="223" align="center"><br />
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><form action="" method="post" name="myform">
<table width="560" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" align="right" width="20%">添加敏感词:<br /></td>
<td width="80%"><input name="txt_word" type="text" id="txt_word" size="50" />
 
<input name="btn_tj" type="submit" class="btn1" id="btn_tj" onclick="return check(myform);" value="添加敏感词" /></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>

</tr>
</table>
<?php

if($_POST){

//这个文件可以自己创建

$filename="filterwords.txt";
if(is_writable($filename)){
$file=fopen($filename,'r+');
}
else{
echo "文件".$filename."不可写";
}
//在文件尾写文件
fseek($file,0,SEEK_END);
$word=$_POST['txt_word'];
fwrite($file,$word);
fwrite($file,"\r\n");
fclose($file);
}
?>

读书人网 >编程

热点推荐