Jump to content

User Inputs!


ckrudelux

Recommended Posts

Hello everyone.I'm trying to make my input fields more safe.So far I have used this htmlspecialchars(); and mysql_real_escape_string(); code.what else can I do to prevent nasty users?

Link to comment
Share on other sites

Very interesting, but god damn is that a dense bit of code! I have only just started to look into PHP and it's at once powerfully elegant and dense as rock.
Link to comment
Share on other sites

You shouldn't need regular expressions for safety.htmlspecialchars() and mysql_real_escape_string() are enough for strings, and for numbers you only need intval() or floatval() (int is a number without decimals, float is a number with decimals).Regular expressions are used to see if E-mail addresses or phone numbers have the right format, but they don't do anything for security.

Link to comment
Share on other sites

Regular expressions actually come from Unix.

Okay.. what symbols to replace I know some but not all of them?
Depends where your data is headed for. For example, if it was intended for a CSV file you might want to remove commas outside strings.
Link to comment
Share on other sites

You shouldn't need regular expressions for safety.htmlspecialchars() and mysql_real_escape_string() are enough for strings, and for numbers you only need intval() or floatval() (int is a number without decimals, float is a number with decimals).Regular expressions are used to see if E-mail addresses or phone numbers have the right format, but they don't do anything for security.
Okay... Then I know :)
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...