I've got a function for making input safe. One takes from a textarea on a form.
The problem is when someone types a few paragraphs in it, using regular sentence stuff like ( ' , . () ? ) it kicks it out and gives them my error message.
How can I keep out the unsafe stuff, but still allow someone to "speak their mind"? Something like a preg_replace maybe?
If so, how can I add it on to my other function?
Thanks
Dan

It seems that everything works perfectly except for the stripslashes won't accept apostrophes.
How do I fix this?

can you give give me an example of the code/data and/or php error if there is one?

Member Avatar for rajarajan2017
<?php 
$str = "Is your name O\'reilly?"; 
  
// Outputs: Is your name O'reilly? 
echo stripslashes($str); 
?>
<?php 
$str = "Is your name O\'reilly?"; 
  
// Outputs: Is your name O'reilly? 
echo stripslashes($str); 
?>

Thank you. Why did I not think of posting that example? Oh well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.