Jump to content

Allow baisc html tags into the database - need help


kee2ka4

Recommended Posts

Hey peeps,

 

I am using the following function below, that uses trim(), strip_tags() and htmlspecialchars() so that I can make my site secure from users entering invalid data.

 

But I would like to have basic html tags to be allowed such as <p>, <b>, <a href>. Is there any way I can allow basic html tags but still make my site secure.

 

function safe_output($value)
{
	$value = trim($value);
	$value = strip_tags($value);
	$value = htmlspecialchars($value);
	return $value;

}

 

I would appreciate advise or pointers on how you guys make your site secure and yet allow users to enter value html tags.

Thanks,

Zub

Ever thought of allowing bbcode just like on here?

 

All I do is something like this:

$name=$_POST['name'];
$age=intval($_POST['age']);
mysql_query("INSERT INTO table (`name`,`age`) VALUES ('".addslashes($name)."','".$age."')");

 

This might be worth reading...

http://php.about.com/od/finishedphp1/qt/slash_function.htm

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.