Ok, I am making a data entry form, however I can't figure out how to make the code accept numbers, spaces, periods, hyphens, and letters. Here is the code that needs to be adjusted.......
if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['street_address'])) {
$sd = mysqli_real_escape_string ($dbc, $trimmed['street_address']);
} else {
}
PHP coding problem with entry form....?
I'm assuming you're looking for a good regex? Try the following instead of what you have there:
/^[A-Za-z0-9 .-]{2,40}$/
If you are not trying to restrict the number of characters between 2 and 40, remove the {2,40}, and replace it with a * for 0 or more or a + for 1 or more characters.
/^[A-Za-z0-9 .-]+$/PHP coding problem with entry form....?
My regular expression syntax may be off a little, but I think you just need to add (without the quotes) ';a-z 0-9'; just after the ';A-Z';.
Like this:
if (preg_match ('/^[A-Za-z0-9 \'.-]{2,40}$/i', $trimmed['street_address'])) {
$sd = mysqli_real_escape_string ($dbc, $trimmed['street_address']);
} else {
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment