Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: safe users commenting

  1. #11
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    this code is too hard for me ;D understood is_nimeric, but this is hard

  2. #12
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Frustrating means annoying and hard.
    Jeremy | jfein.net

  3. #13
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    can you write me an example with $msg variable??

  4. #14
    Join Date
    Jul 2009
    Location
    Coquitlam BC Canada
    Posts
    46
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    frustrating?
    frus·trate (frstrt)
    tr.v. frus·trat·ed, frus·trat·ing, frus·trates
    1.
    a. To prevent from accomplishing a purpose or fulfilling a desire; thwart: A persistent wind frustrated my attempt to rake the lawn.
    b. To cause feelings of discouragement or bafflement in.
    2. To make ineffectual or invalid; nullify.
    [Middle English frustraten, from Latin frstrr, frstrt-, from frstr, in vain.]
    frustrater n.
    frustrating·ly adv.

  5. #15
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    please people, help me with this....

    I have two variables $user and $pass
    What php script will not let users to insert characters like .?/,|\][)(-+ into my login and pass inputs. Thanks

  6. #16
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    The following will say that there are strange characters if there is anything other than a capital or lower case letter. Spaces are also counted as a strange character in this snippet of code.
    PHP Code:
    <?php
    $test
    ='thisissometext';
    if(
    preg_match('/[^a-zA-Z]/'$test)) {
    echo 
    "YES, odd characters were found";
    }
    else {echo 
    "NO odd characters were found";}
    ?>
    This is an example of PCRE (Perl Compatible Regular Expressions).

    I have a tutorial on it here http://www.animeviews.com/article.ph...ry=programming
    and here http://www.animeviews.com/article.ph...ry=programming
    and have a page of examples here http://www.animeviews.com/article.ph...ry=programming
    Last edited by james438; 11-17-2009 at 07:54 PM. Reason: typo, slight rewording
    To choose the lesser of two evils is still to choose evil. My personal site

  7. The Following User Says Thank You to james438 For This Useful Post:

    auriaks (11-14-2009)

  8. #17
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    if(preg_match('/\W/', $password, $nick, $name, $telephone)) {
    $value = '1';
    }

    What is wrong with this command? I got : Warning: preg_match() expects parameter 4 to be long, string given in /home//domains/l//register.php
    I want to check these 4 strings if is symbols into them, how i have to change it?
    Last edited by auriaks; 11-17-2009 at 07:04 PM.

  9. #18
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    You are trying to preg_match an array. I am pretty sure you can't do that. At least I can't read anywhere in the documentation where you can and I have not been able to do so. You can use arrays with preg_replace, but that is a different function and as you can probably guess it is a regular expression function designed to find matches and replace the matches found, but doesn't tell you IF a match was found.

    What you are asking for can best be done with a loop like

    PHP Code:
    <?php
    $num
    =0;
    $all=array("th%is","that","& the next thing");
    foreach(
    $all as $t){$num++;
    if(
    preg_match('/\W/'$t)) {
    echo 
    "value $num MATCHES<br>";
    }
    else echo
    "value $num DOES NOT MATCH<br>";}
    ?>
    Remember, though, \W will match letters numbers and the underscore _
    Last edited by james438; 11-17-2009 at 09:44 PM. Reason: added last sentence.
    To choose the lesser of two evils is still to choose evil. My personal site

  10. #19
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    What about this?
    PHP Code:
    if(preg_match('/\W/'$password)) {
            echo 
    "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected!!!</b></font></center>";
            
    $string '1';
            } else {
            if(
    preg_match('/\W/'$nick)) {
            echo 
    "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>";
            
    $string '1';
            } else {
        
    $string '0';

    ...
    if (
    $string == 1) {die} else {work
    it is working for me...

  11. #20
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    else should be the last else listed. Previous else statements should be elseif.

    PHP Code:
    if (preg_match('/\W/'$password)) {
            echo 
    "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected!!!</b></font></center>";
            
    $string '1';
    }
    elseif (
    preg_match('/\W/'$nick)) {
            echo 
    "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>";
            
    $string '1';
    }
    else 
    $string '0';
    if (
    $string == 1) die; 
    else 
    work
    curly brackets are not necessary if there is only on statement to execute. If there are two or more you will need to use the curly brackets, but you can use them if you want. I am just mentioning it in case you didn't know.
    Last edited by james438; 11-18-2009 at 12:00 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

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
  •