#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Montreal, Canada
    Posts
    72
    Rep Power
    15
    I need urgent help. I have been trying to solve this problem for the last 5 hours and I now simply give up. I come to u Devshedders to deliver me

    Here is the problem, I have a form that takes only 1 input. This input is a USER_NAME for a database. Now, this USER_NAME can not contain any special characters that are not allowed in the name of a file e.g. ?,{,},[, space and _ symbol.

    I have been looking all over the web for some PHP script(or anything user friendly like javascript) to help me with this. I have seen some PERL script but I really can't understand it well enough to try and do a translation into PHP.

    If you will please help me I will be extremly grateful. I told my site users that I would allow them to register by Monday and I feel bad that I have not delivered on that promise due to reasons beyond my control.
  2. #2
  3. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    no offense, but i wouldn't call this beyond your control

    if you want to check a string and make sure it only has letters or numbers, use something like:

    if(preg_match("/[^a-zA-Z0-9]/", $var))
    {
    // invalid username
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Montreal, Canada
    Posts
    72
    Rep Power
    15
    Thanks, I was complicating my life by trying to call the strlen() function, read the string into a char array and do strcmp character by character in the array except I am not too good in transfering C to PHP and I am a big time newbie in PHP.

    One more question, I have seen this around the forum and I think I will even go do a small search but if you are online and can reply what is the PHP function to convert a string into lowercase. Thanks in advance
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16

Similar Threads

  1. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 11:56 AM
  2. SDL_ttf string parsing
    By aerea in forum C Programming
    Replies: 0
    Last Post: January 12th, 2004, 08:22 PM
  3. Parsing and formating a string through XSL
    By relativity in forum XML Programming
    Replies: 3
    Last Post: January 8th, 2004, 07:35 AM
  4. Multiple word string input problems
    By ocean97 in forum C Programming
    Replies: 9
    Last Post: January 6th, 2004, 03:46 PM
  5. trouble with string and input
    By maalox04 in forum C Programming
    Replies: 1
    Last Post: December 8th, 2003, 02:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo