English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how do you use the preg_replace command to keep people from entering special characters in form fields? I'm trying to keep from being subject to an SQL injection attack. I've read articles, and tutorials on different websites, but I'm not understanding how to use the function. Examples would be greatly appreciated.

2006-10-05 04:01:06 · 1 answers · asked by detroitkid17 2 in Computers & Internet Programming & Design

1 answers

the best way, if you are going with a regular expression, is to replace everything that is not in the allowed characters. Your regular expression would look something like /[^a-zA-Z0-9]/ (the ^ at the beginning of the group means match everything that is not in this group, where without the ^ it would match everything in that group).

2006-10-05 04:55:27 · answer #1 · answered by John J 6 · 1 0

fedest.com, questions and answers