Jump to content

form validation


adam291086

Recommended Posts

Determine what fields you are passing through (from the user).

Put each field through a rigorous test based on what type you expect it to be.

 

i.e. if you're expecting an integer is the is_int() function.

If you're also expecting it to be in a range, then if x>0 and x<50 will do. Or you could write a range($lower,$upper) function to do that for you.

 

If you want avoid characters in strings then perform a regular expression.

 

It's all basic really.

ANY input from a user (whether $_POST OR $_GET) is insecure and should be verified before delivering.

Link to comment
Share on other sites

mysql_real_escape_string will only work if you are utilising a MySQL connection at the time, which might not be the case, and thus will throw a warning (perhaps causing erratic behaviour dependent upon your setup).

Of course you could mention just mysql_escape_string() instead, however again I would say that unless you are utilising MySQL this function might not give you expected results. Are the quote parameters not different for different databases?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.