Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: safe users commenting

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

    Default

    I am amending my previous statement. You cannot use multiple "else" in an "elseif" statement.

    If someone else knows better, please correct me if I am wrong
    Last edited by james438; 11-18-2009 at 08:24 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #22
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    How to do then?

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

    Default

    Just read my post and you will see the answer as well as a sample script. You can also read more about it at http://php.net/manual/en/control-structures.elseif.php
    To choose the lesser of two evils is still to choose evil. My personal site

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

    Default

    what if I have more than 3 statements and if's?

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

    Default

    Code:
    <?php
    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'; 
    }
    elseif (preg_match('/\W/', $occupation)) { 
            echo "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>"; 
            $string = '1'; 
    }
    elseif (preg_match('/\W/', $name)) { 
            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;
    ?>
    To choose the lesser of two evils is still to choose evil. My personal site

  6. #26
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    ok, i'll try... Thanks.

  7. #27
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    preg_mach doesnt work for me... it isnt detecting symbols... idk why, but in other page it works

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

    Default

    what i have to write in here:
    (preg_match('/\W/', $password)
    if I want to detect 'word characters', 'numbers', 'underscores', '@' , '.' , and ',' ??

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

    Default

    I suspect that you are racing into this a bit too fast. regular expressions is one of the most complex aspects of php and takes a little time to understand.

    \w is the opposite of \W.
    \w will match word characters. Word characters is defined as all letters, numbers, and the underscore.

    The following will detect whether any letters, numbers, underscores, periods, commas, or 'at' symbols are found in your string.

    Code:
    <?php
    $test='.,@';
    if(preg_match('/[\w,.@]/', $test)) 
    {echo "YES, there was at least one word character ',', '.' or '@' symbol detected.";}
    else 
    {echo "NO there was not one word character ',', '.' or '@' symbol detected.";}
    ?>
    The square brackets says that the things we want to find between them can be in any order.
    To choose the lesser of two evils is still to choose evil. My personal site

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

    Default

    maybe, because i used this a lot:
    $tag = str_replace('*', '/*', $tag);

    and i dont know how to change ' symbol to /'
    if i write like that:
    $tag = str_replace('' '/'', $tag); it will be bad

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
  •