一 代码
class="php"><?php { $user=$_POST[user]; $text=$_POST[text]; if(substr_count($user,'大人')>0 or substr_count($text,'大人')>0 or substr_count($user,'小人')>0 or substr_count($text,'小人')>0) { echo "<script>alert('您输入的内容中有指定的关键字'); history.back();</script>"; } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>substr_count()函数的应用</title> <style type="text/css"> <!-- .STYLE1 { font-size: 13px; font-weight: bold; } --> </style> </head> <body> <table width="720" border="0" cellspacing="0" cellpadding="0"> <tr> <td></td> </tr> </table> <table width="720" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="121"></td> <td width="584" height="454"><table width="584" height="454" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="top" bgcolor="#F2F7FB"> <form name="form1" method="post" action="index.php"> <table width="580" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="89" height="30"> </td> <td width="491"> </td> </tr> <tr> <td align="right"><span class="STYLE1">名称: </span></td> <td height="24"><input name="user" type="text" id="user" size="50" /></td> </tr> <tr> <td align="right"><span class="STYLE1">内容: </span></td> <td><textarea name="text" cols="60" rows="10" id="text"></textarea></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Submit" id="Submit" value="提交"></td> </tr> </table> </form> </td> </tr> <tr> <td height="48"></td> </tr> </table></td> <td width="15"></td> </tr> </table> </body> </html>
?
二 运行结果