I really don't understand regular expressions and was wondering what the following regular expressions do I wanted my address and name to except periods hyphens letter uppercase and lowercase and numbers.
Is my regular expressions living up to there job and is there need for improvement? Plus if some one can break down the regular expressions '/^[A-Z0-9 \'.-]{1,255}$/i'
so I can understand every part better. Thanks
Here is the php code.
if (preg_match ('/^[A-Z0-9 \'.-]{1,255}$/i', $_POST['address'])) {
$address = mysqli_real_escape_string($mysqli, htmlentities($_POST['address']));
} else {
echo '<p class="error">Please enter your address!</p>';
}
if (preg_match ('/^[A-Z0-9 \'.-]{1,255}$/i', $_POST['name'])) {
$name = mysqli_real_escape_string($mysqli, htmlentities($_POST['name']));
} else {
echo '<p class="error">Please enter your name!</p>';
}