Re: How can I check for characters in a $_POST[] variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/22/2011 10:54 AM, 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.

if(!ctype_alnum($_POST['username'])) {
   // is not alpha numeric
}

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux