Reputation: 41
Im looking for a regex to make sure noboy haxes in stuff I dont want in a guesbook I made in PHP. Such as, scripts, sqlinjections, html etc. But still I want the users to be able to use as many chars as they can (ex :)(/?!.,"&-_) without doing the site less safe.
ideas of how that regex would look like?
Upvotes: 0
Views: 335
Reputation: 87
Use PDO or MySQLI with prepared and bound statements. If you do it right, you won't need to worry about Regex - unless you really want to go over-kill with security ;)
Upvotes: 1
Reputation: 9011
htmlspecialchars($output)
Note that htmlspecialchars
helps prevent XSS, not SQL injection. To prevent SQL injection, use prepared statements. To prevent CRSF, you can do a little research.
Upvotes: 3