PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if(!preg_match('/[^a-zA-Z\_\-0-9]+$/',$username))
{
$message="Your username contains illegal characters on spaces.";
unset($username);
include 'index.php'; // Show the form again!
exit();
}
if(!preg_match('/[^a-zA-Z\_\-0-9]+$/',$username))
{
$message="Your username contains illegal characters on spaces.";
unset($username);
include 'index.php'; // Show the form again!
exit();
}
if(!preg_match('/^[a-zA-Z_\-0-9]+$/',$username))
{
$message="Your username contains illegal characters on spaces.";
unset($username);
include 'index.php'; // Show the form again!
exit();
}
Is this what you are trying to do.
If you don't put ^ at the begginning and $ at the end of reg exp. there might be additional symbols, hence breaking the required rule