Re: RE: How can I check for characters in a $_POST[] variable?
| From: | Nilesh Govindarajan | Date: | Thu, 22 Sep 2011 13:38:29 +0000 |
| Subject: | Re: RE: How can I check for characters in a $_POST[] variable? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314985@lists.php.net to get a copy of this message | ||
On 09/22/2011 09:24 PM, Eric wrote:
> if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) {
> echo "<p style=\"color:red;font-weight:bold;margin-left:95px\">";
> echo "Username must only contain A-Z and 0-9</p>";
> include("register.html");
> exit;
> }
>
> I used the code above but I now get this error message
>
> Warning: preg_match() [function.preg-match]: Unknown modifier '^' in C:\Documents and
> Settings\iceweasel\Desktop\XAMPP\relik.ath.cx\forum\register.php on line 2
>
> I don't like to run php with errors off so I wanna ask how I can fix this.
Oh damn, I just forgot that the pattern is to be enclosed between
delimiters. Glad that you found the fix using ctype_alnum though. A new
learning for me.
--
Nilesh Govindarajan
http://nileshgr.com