
PHP Validations: Regular Expressions
This question seems to be a regular expression syntax problem, not necessarily a PHP problem. I would suggest Googling some regular expression tutorials to find some readily available regex classes.
To give you a little of a step to begin with:
1) The php function eregi is case insensitive, so there really isn't a need to validate for both uppercase and lowercase letters with regex.
2) secondly,
http://www.regular-expressions.info/ is a great resource for regular expression tutorials, with many available samples.
3) In response to your question #4, [a-zA-Z0-9_] is specifying a regex class that basically says any alphanumeric number, or an underscore of any number of characters.
4) In response to question #5, i would always escape characters, and do everything possible to prevent sql injection, except i wouldn't use stripslashes, as it can be worked around: example
echo stripslashes("\test"); #outputs: test
echo stripslashes("\\test"); #outputs: test
echo stripslashes("\\\test"); #outputs: \test
echo stripslashes("\\\\test"); #outputs: \test
Better off using mysql_real_escape_string as this function was built to prevent sql injection. See the PHP manual for a best practice example of executing a query to prevent sql injection:
http://ca.php.net/manual/en/fu...string.php (example #3).
Hope that gets you started.
_________________
somewhere a clock is ticking...