View Full Version : Best protection against SQL injection.
05-07-2006, 08:45 PM
Thanks for helping, :thumbsup:
05-07-2006, 10:34 PM
When you set up an input field you know exactly what you want the field to be used for and so should have a good idea of what entries are valid for that particular field. So what you want to do on the server as soon as you retrieve the field is to validate the field as accurately as you can against what that expected input would be. If built-in functions exist that will handle the validation then use those. If the particular format doesn't fit a built-in function then use a regular expression. If only specific values are allowed (eg. from a select list) then validate that the value received is one from the list and discard anything else.
You also want to use htmlentities() for filtering output to the screen and mysql_real_escape_string for filtering data being written to mysql databases (and the closest equivalent if using a different database).
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.