![]() |
PHP Script to Sanitise Form Input for a MySQL DatabaseThe following function can be used to remove potentially dangerous characters from a form input field before the data is inserted into a MySQL database: function makeSQLSafe($str) $str = mysql_real_escape_string($str); return $str; Here's an example of how the function would be used in practice. We would obtain the form input in the normal way, e.g. as follows: $ReviewDesc=$_POST['txtReviewDesc']; Then when the various field values are input into the database, we cleanse them by calling the makeSQLSafe function on them as follows: //database query
|
|
All Content ©2020 WebRef.eu |