Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1

    Default how to trap special chracters and digits in php?


    how to trap special chracters and digits in php?

    i used ctype_alpha() para ma trap ang special char and digits pero if naa space ang last name like (de la cruz) iya apilon ug trap ang space so ang result ma tarp tanan special char & digit pero no space imong last name like (de la cruz)!

    unsaon ni? naa bay laing function or way para ma trap?


    salamat sa debug................. your answer will be a lifeline sa akong thesis!

  2. #2
    gamit siguro ug regular expressions bay. . .

  3. #3
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    if you can manage to read and write codes then study...

    PHP: POSIX Regex - Manual
    Regular Expressions PHP Tutorial

    or you can post your sample code so others can help you.

  4. #4
    Bitaw maypa sample code.

    Pero solution nimo REGEXP, preg_replace ra gyud, hehe.

  5. #5
    or pwede pud imo i split ang each character sa string into an array of characters then per character imo manipulation/checking. . .

  6. #6
    if(trim($_POST['fname'])==''||!ctype_alpha(trim($_POST['fname']))){
    $errorlist[]='First Name is Empty or Must be All Alpha Characters!';
    }

    123=error

    !!@@=error

    12ewew=error

    wewew12=error

    !@wew=error

    wqwq!@@=error

    john=NO ERROR

    but the bug is JOHN JOHN / DE LA CRUZ = ERROR!

    mao ni ang bugs mga master if mo input ko naay space iya e treat ang space as special character unsaon mani??

  7. #7
    unfortunately bro.... ang trim() function kay only removes white spaces outside sa text... not inside...

    example:

    $var =" the fox ";
    $var = trim($var);
    echo $var;

    outputs: "the fox"

    so kung mag ctype_alpha() ka... " " white space is not part of the "C locale letters"... so mu error jud na xa...

    so try this... i think mao na jud ni ang imong g huwat...


    CODE:
    $name = $_POST[fname];

    $name = trim($name); // para xur na walay white space outside the word

    $tempname = str_replace(" ", "", $name); // replacing white spaces with no space...

    if( $name == "" || !ctype_alpha($tempname) )
    {
    $errorlist[]='First Name is Empty or Must be All Alpha Characters!';
    }

  8. #8
    @tynum

    salamat kaayo master mao nlang ni kuwang sa among thesis ang trappings na walay bug yes thnak you kaayo


    ikaw ang daan patungo sa aming kinabukasan haha bitaw salamt kaayo

    ug sa tanan salamats

  9. #9
    wla ka ni try sa regular expression bro? may nice man cguro to...

  10. #10
    try this one, this is a good read

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. How to create a search and filtering box in webpage?
    By W.Axl Rose in forum Websites & Multimedia
    Replies: 17
    Last Post: 02-29-2012, 05:21 PM
  2. How to start a business and make it grow.. Learn from the others...
    By arnoldsa in forum Business, Finance & Economics Discussions
    Replies: 25
    Last Post: 11-22-2011, 06:03 PM
  3. Replies: 127
    Last Post: 03-31-2010, 05:08 PM
  4. Replies: 4
    Last Post: 03-02-2010, 07:33 AM
  5. how to configure the dial up internet in my computer?
    By dudz in forum Computer Hardware
    Replies: 14
    Last Post: 02-14-2006, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top