Khalil
IDK
Hello everyone, so you might have experienced your self in some time some "Database" or "Table" Drops, or you might have a friend that have experienced it him self, i have experienced that situation too, but then i continued my "studies" on how to secure your self from drops, and finally made up this easy and simple code.
So, if you have a global or config file, you open it and include this class into it:
now you got that into your config file just save and close, then go to your register or login page or anywhere where you have a form.
For an example you have a login page, just open it and look for this.
and then change it to this:
and you can do the same thing for the password and on your register page for email, firstname....
Basically this is used in everywhere there is a post method (haven't been tested on get methods).
See how this was easy ?
btw, don't forget on your page to require your config file by doing the following:
Hope i helped, enjoy !
-Khalil
So, if you have a global or config file, you open it and include this class into it:
PHP:
class userCore { // This is the core of the entire class, it mainly insures security.
public function clean($str) {
return stripslashes(htmlspecialchars(mysql_real_escape_string($str)));
} //This function ends here.
public function secure($input) { //Secures that no-one registers/logs in as e.g "DROP database" and drops your entire database.
return addslashes(htmlspecialchars(trim(strip_tags($input))));
} //Function ends here.
} //Class ends here.
$core = new userCore; //Creates the core-> var. May be used as $core->clean($var) or $core->secure($var).
now you got that into your config file just save and close, then go to your register or login page or anywhere where you have a form.
For an example you have a login page, just open it and look for this.
PHP:
$username = $_POST['username'];
and then change it to this:
PHP:
$username = $core->secure($_POST['username']);
and you can do the same thing for the password and on your register page for email, firstname....
Basically this is used in everywhere there is a post method (haven't been tested on get methods).
See how this was easy ?
btw, don't forget on your page to require your config file by doing the following:
Code:
<?php require_once "link to your global or config file"; ?>
Hope i helped, enjoy !
-Khalil