SQL query like this,
$uid = $_GET['id'];
$result = mysql_query("SELECT name, lastname, email FROM users WHERE id = '$uid'");
How to print a 404 header if the id != value of $_GET['id']?
SQL query like this,
$uid = $_GET['id'];
$result = mysql_query("SELECT name, lastname, email FROM users WHERE id = '$uid'");
How to print a 404 header if the id != value of $_GET['id']?
$uid = mysql_real_escape_string($_GET['id']);
$result = mysql_query("SELECT name, lastname, email FROM users WHERE id = '{$uid}'");
if (!result || mysql_num_rows($result) == 0)
header("Status: 404 Not Found");
Also note, you should move away from deprecated mysql_*
functions.
Also also note, Bobby Tables.
Not really sure which id
you refer to, but you are looking for something along the lines of:
if (id != $_GET['id'])
header("Status: 404 Not Found");