嗨,我正在运行一个 mysql 插入查询,这个想法是用户可以向用户个人资料提交评论,但我想知道是否有一种方法可以阻止令人反感的词语、链接并防止人们使用博客链接等向其发送垃圾邮件。
我会使用 php if 语句来说明忽略这些关键字吗?“f*ck”等,我觉得这样的唯一问题是我必须在忽略语句中包含每个单词,
或者我会在我的mysql中包含一些东西,无论哪种方式我都想阻止所有链接插入到表单中,
有人可以给我一些指导并告诉我我将如何做到这一点,谢谢
html:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<textarea name="review_recipient" id="review_recipient" maxlength="180" cols="33" rows="5" style=""></textarea><label style="">Who is the Review from?</label>
<br/>
<textarea name="review_content" id="review_content" maxlength="180" cols="33" rows="5" style=""></textarea>
<label style="">Say Something...</label>
<input name="add_review" type="image" src="http://www.playtimeboys.com/assets/img/icons/save-edit.png" BORDER="0" ALT="SUBMIT!"class="review_submit4" /></form>
php/mysql:
<?php ob_start(); ?>
<?php
// check if the review form has been sent
if(isset($_POST['review_content']))
{
$content = $_POST['review_content'];
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$content = stripslashes($content);
}
//We check if all the fields are filled
if($_POST['review_content']!='')
{
{
$sql = "INSERT INTO ptb_reviews (id, from_user_id, to_user_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";
mysql_query($sql, $connection);
$_SESSION['message']="<div class=\"infobox-wallpost\"><strong>Thank You</strong> - Your review has been sent and is awaiting approval.</div><div class=\"infobox-close4\"></div>";
header("Location: {$_SERVER['HTTP_REFERER']}");
} } } } ?>