i tried a search on this already. found tons of threads on preventing injection attacks...but couldnt find anything related to my specific question.
i use a function i grabbed out of a book to escape data submitted through an online form to try and prevent injection attacks. this is the code:
function escape_data($data)
{
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
if (function_exists('mysql_real_escape_string'))
{
$data = mysql_real_escape_string(trim($data));
}
else
{
$data = mysql_escape_string(trim($data));
}
return $data;
}
now im trying to use this function on a textarea form field that when its submitted, it gets inserted into a database. when i test this...it all seems to be working as it should except when i display the submitted info back into the textarea...it doesnt display as i originally inputted it. here is an example:
testing this
testing this
testing this
when i hit submit...it is inserted into the database like this:
testing this\r\ntesting this\r\ntesting this\r\n
and it displays like it is inserted in the above code block. i want it to display like it was originally typed into the textarea befoer submitting it. any help with this would be greatly appreciated.