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

Thread: Classes

  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Classes

    So heres my class:

    PHP Code:
    class secure
     var 
    $data2;
     
     function 
    check() {
     
    $data2 =mysql_real_escape_string($data2);
     
    $data2 htmlentities($data2);
     
    $data2 strip_tags($data2);
     }
     } 
    Basically what i want to do, is everytime i have a variable in my page that say is inputted from the user, say $message = ($_POST['mesage']);, then i want this to take the data and check it for all of the above.

    PHP Code:
    $username = ($_POST['username']); 
    $check = new secure;
    $check->data2 $username;
    $check->check();
    echo
    "$username<br>"
    But the problem is this doesn't seem to be working.

    I typed in my username as <b>username</b> and it still comes up bold when it clearly should remove the bold statements.

    Any help?

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Replace
    $data2 =mysql_real_escape_string($data2);
    with
    $data2 =mysql_real_escape_string($this->data2);

  • #3
    New Coder
    Join Date
    Dec 2006
    Location
    Denver, Colorado
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you use htmlentities() first, you're replacing "<b>" and "</b>" with the html entity string &amp;lt;b&amp;gt; so strip_tags() cannot parse it, I think.

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks, got it to work!


  •  

    Posting Permissions

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