从php表单中删除字符

时间:2014-04-01 17:51:03

标签: php forms

我试图从php表单中剥离某些字符和关键字而没有太多运气 我想要的是模块化筛选器列表,以删除网址和某些关键字。目前我只想删除http链接,同时保留允许的域名。在本例中是example.com

<?php //Check whether the form has been submitted
 if (array_key_exists('check_submit', $_POST)) {    
//Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag)    
$_POST['Comments'] = nl2br($_POST['Comments']);     //Check whether a 
$_GET['Languages'] is set    
}

   //Let's now print out the received values in the browser   
 echo "<br />{$_POST['Comments']}<br /><br />"; 
} 
else 
{
    echo "You can't see this page without submitting the form."; 
} 
?>

1 个答案:

答案 0 :(得分:0)

我总是使用:

$data = "<b> some text ///, test</b>"    
htmlentities(strip_tags(mysql_real_escape_string($data)));

希望有所帮助!