Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Checking for a single character

    Hello,

    Okay I need to know how the heck I can check a form field check to make sure it has a certain character in it....

    For instance

    if($Uname== ?????){
    error("Sorry but you dont have the character");
    }else{
    error("YOU DO HAVE THE CHARACTER");

    }

    Any help would be greatly appreciated!
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the regex way:
    PHP Code:
    if (!ereg("[%]+"$Uname)) {
         
    error("Sorry but you dont have the character");
    } else {
         
    error("YOU DO HAVE THE CHARACTER"); // at least one time

    or the php strstr() function
    PHP Code:
    if (!strstr($Uname"%")) {
         
    error("Sorry but you dont have the character");
    } else {
        
    error("YOU DO HAVE THE CHARACTER"); // at least one time 

    I seam to remember that the second one should be faster, but i'm not sure + you wount notice the difference.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey RAF It worked Perfectly thanks again!!!
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome. Glad you got it running.


  •  

    Posting Permissions

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