Filltering

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Filltering

    how do I fillter chars like ` & ^ %
    Visit my site

    #2
    you can try something like this:

    PHP Code:
    $text = preg_replace('/[^[:alnum:]\-\.\_\^]/', '', $text); 
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      How would I put that in an if statment?
      Visit my site

      Comment


        #4
        why into if statement?
        Advertise your mobile site for FREE with AdTwirl

        Comment


          #5
          Ok here is what I got
          PHP Code:
          $text = preg_replace('/[^[:alnum:]\-\.\_\^]/', '', $username);
          if(
          $text == true)
                  {
                  die (
          "Unsupported character(s)");
                          } 
          Last edited by ripkk2tfk; 09.01.10, 13:14.
          Visit my site

          Comment


            #6
            no, for what you need the filtering? password or username?
            Advertise your mobile site for FREE with AdTwirl

            Comment


              #7
              I want to remove any special characters from username, password to help prevent mysql injection as for the email I need to allow the @ symbol
              Visit my site

              Comment


                #8
                to prevent mysql injection use: mysql_real_escape_string
                PHP: mysql_real_escape_string - Manual
                Advertise your mobile site for FREE with AdTwirl

                Comment


                  #9
                  Is that all I should use?
                  Visit my site

                  Comment


                    #10
                    yes thats all
                    Advertise your mobile site for FREE with AdTwirl

                    Comment


                      #11
                      Thanks Gumslone
                      Visit my site

                      Comment


                        #12
                        one other way

                        put this in your confg.php or ini.php


                        PHP Code:
                        function scharin($word)
                        {
                          
                        $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
                          for(
                        $i=0;$i<strlen($word);$i++)
                          {
                            
                        $ch = substr($word,$i,1);
                          
                        $nol = substr_count($chars,$ch);
                          if(
                        $nol==0)
                          {
                            return 
                        true;
                          }
                          }
                          return 
                        false;
                        } 

                        put this line in your register.php and you replace $login to your user name etc

                        PHP Code:
                        if(scharin($login) == true) $error=$error.'Invalid Characters in Nick!<br/>'; 
                        and


                        PHP Code:
                        if(strlen($login)<3) $error=$error.'Nick should be Minimum of 3 words!<br/>'; 


                        if you need more and strong filter send me pm will tell you
                        Last edited by GiLL; 09.01.10, 16:19.
                        left wap stuff

                        Comment


                          #13
                          Originally posted by GiLL View Post
                          put this in your confg.php or ini.php


                          PHP Code:
                          function scharin($word)
                          {
                            
                          $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
                            for(
                          $i=0;$i<strlen($word);$i++)
                            {
                              
                          $ch = substr($word,$i,1);
                            
                          $nol = substr_count($chars,$ch);
                            if(
                          $nol==0)
                            {
                              return 
                          true;
                            }
                            }
                            return 
                          false;
                          } 

                          put this line in your register.php and you replace $login to your user name etc

                          PHP Code:
                          if(scharin($login) == true) $error=$error.'Invalid Characters in Nick!<br/>'; 
                          and


                          PHP Code:
                          if(strlen($login)<3) $error=$error.'Nick should be Minimum of 3 words!<br/>'; 


                          if you need more and strong filter send me pm will tell you
                          this is not a good solution to prevent mysql injection
                          Advertise your mobile site for FREE with AdTwirl

                          Comment


                            #14
                            It would be nice just be use
                            1234567890abcdefghijklmnopqrstuvwxyz
                            nothing else
                            Visit my site

                            Comment


                              #15
                              This thread is going to help alot of people who are new to Php I personally find filtering to be a pain.
                              Visit my site

                              Comment

                              Working...
                              X