bug #54041 - http post vars are set before processing. changed order to make example give shown output

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@308511 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
David Tajchreber 2011-02-20 22:41:18 +00:00
parent d9b0caea3f
commit f97cf90f64

View file

@ -83,14 +83,14 @@ $query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
<programlisting role="php">
<![CDATA[
<?php
// Query database to check if there are any matching users
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
mysql_query($query);
// We didn't check $_POST['password'], it could be anything the user wanted! For example:
$_POST['username'] = 'aidan';
$_POST['password'] = "' OR ''='";
// Query database to check if there are any matching users
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
mysql_query($query);
// This means the query sent to MySQL would be:
echo $query;
?>