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
https://forums.phpfreaks.com/topic/75505-form-validation/#findComment-381937
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
https://forums.phpfreaks.com/topic/75505-form-validation/#findComment-381968
Share on other sites

Archived

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

×
×
  • 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.