PHP security tips

NEVER trust user input

User the following validation methods for input.

$username = mysql_real_escape_string($_POST[‘username’]);
$password = mysql_real_escape_string($_POST[‘password’]);
// Query database to check if there are any matching users
$query = “SELECT * FROM users WHERE user=’$username’ AND   password=’$password'”;

$variable = htmlentities($_GET[‘page’], ENT_QUOTES, ‘UTF-8’);
// or even more secure
$variable = strip_tags($_GET[‘page’]);

Posted in Uncategorized
One comment on “PHP security tips
  1. Thanks for posting this awesome article. I’m reading your blog since a long time
    already but I never compelled to leave a comment. I registered your
    blog in my rss feed and shared it on my Twitter.
    I will come back for sure to check your future articles!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: