Hello all,
I am trying to ensure that a given username consists of alpha-numeric characters only. Here's the code:
And here's the output to the browser:PHP Code:<?php
$username = "madmax's";
if (preg_match('/[1-9|a-z|A-Z]{6,14}/', $username)) {
echo 'Preg.. MATCH! $username is: ' . $username . '<br />';
} else {
echo 'No preg_match. Username may consist of alpha-numeric characters only';
}
?>
---
Preg.. MATCH! $username is: madmax's
---
What's wrong with my code? The apostrophe in madmax's should have meant the pregmatch failed..


Reply With Quote
Bookmarks