[Redirecting thread back to the list for the benefit of others.]
On 9/22/11 13:38, "Eric" wrote:
>So is $_POST["username"][0] appropriate or does that only work
>with normal variables?
As far as this sort of manipulation goes, $_POST is just like any other
variable. Referencing the 0th element
On 09/22/2011 10:36 PM, Robert Williams wrote:
> As an alternative to the regular expression approaches already provided by
> others, you could also use ctype_alnum():
>
> if (ctyp_alnum($_POST['username'])) {
>//username contains only letters and numbers
> } else {
>//username contains ch
As an alternative to the regular expression approaches already provided by
others, you could also use ctype_alnum():
if (ctyp_alnum($_POST['username'])) {
//username contains only letters and numbers
} else {
//username contains characters other than letters and numbers
} //if-else
Docs:
Or... just use:
if(preg_match('/^[A-Za-z0-9]+$/', $_POST['username']) !== 0) {
// string contains other characters, write the code
}
You can see this regex in action here: http://regexpal.com/?flags=®ex=
^%5BA-Za-z0-9%5D%2B%24&input=myusername01
If you put anything different of A-Za-z0-9 the re
Use this regex:
if(preg_match('/[[:punct:]]/', $_POST['username']) !== 0) {
// string contains other characters, write the code
}
The POSIX class [:punct:] means matches any punctuation and symbols in your
string and that includes [!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]
Regards,
Igor Escobar
*Soft
On Thu, Sep 22, 2011 at 7:55 AM, Eric wrote:
> I have this problem when using php because my computer recognizes
> the characters "." and ".." as an existing file when I use file_exists.
> Also
> I want to check $_POST["username"] for characters other then A-Z a-z and
> 0-9.
> If it contains anyt
On Thu 22 Sep 2011 08:25:29 PM IST, Eric wrote:
> I have this problem when using php because my computer recognizes
> the characters "." and ".." as an existing file when I use file_exists. Also
> I want to check $_POST["username"] for characters other then A-Z a-z and 0-9.
> If it contains anythin
7 matches
Mail list logo