Jump to content

User Inputs!


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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...