首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

写下敏感词

2012-09-01 
写入敏感词script languageJavaScriptfunction check(myform){if(myform.txt_word.value){alert(

写入敏感词
<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">&nbsp;</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" />
                          &nbsp;
                        <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);
}
?>

热点排行