<?php
$number = isset($_GET["number"]) ? $_GET["number"] : 0;
$number = (is_numeric($number) && ctype_digit($number)) ? $number : 0;
if ($number == 0) {
/* bad input - do something here
since 1 is more than likely a valid record you may not want to give
out that data based on bad input.
*/
exit;
}
// ... connection code ...
$result = mysql_query("SELECT id.email FROM people WHERE id = $number");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0]; // 42
echo $row[1]; // the email value
?>
There are many different ways to go about sanitising your input, some
of which you can download.
...and here's a good source (found on
bobby-tables.com):
http://download.oracle.com/oll/tutorials/SQLInjection/index.htm
--
Norman
Registered Linux user #461062
-Have you been to
www.php.net yet?-