SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking for special characters

    lo all
    question:
    i want to make sure all a variables characters are a-z - non case specific, and can also contain 0-9
    i was thinking something like
    $usernamecheck = function("$username");
    if($usernamecheck == $username){
    proceed();
    }
    else{
    die(specialcharacters());
    }
    i just dont know the correct function to do this

  2. #2
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To check whether a value contains only alphanumeric characters:

    PHP Code:
    if (ereg ("^[[:alnum:]]+$",$aString))
    {
      
    //do if true
    }
    else
    {
      
    //do if false


  3. #3
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks man


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •