// validate text input fields if (trim($_POST['title']) == '') { $errorList[] = 'Invalid entry: Title'; }
Validate? Just by removing trailing spaces? People trusting this book's advice will be very sorry soon.
// and later in the script...
$query = "INSERT INTO news(title, content, contact, timestamp) VALUES('$title', '$content', '$contact', NOW())"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
One more example:
// generate and execute query $id = $_GET['id']; $query = "SELECT title, content, contact FROM news WHERE id = '$id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
No validation at all! User input thrown into the database without any check!
It's unbelievable that in 2005, after all the outrage and cry about SQL injection ther is still a new book proposing such horrible code!
Paul Dubois' last edition of MySQL covers, among other interesting topics, using Pear::DB with placeholders.
Look at the examples given in the companion web site. There is code like the following, which is highly vulnerable to SQL injection attacks:
Validate? Just by removing trailing spaces? People trusting this book's advice will be very sorry soon.
One more example:
No validation at all! User input thrown into the database without any check!
It's unbelievable that in 2005, after all the outrage and cry about SQL injection ther is still a new book proposing such horrible code!
Classified?
Have you read it?
The original document says "UNCLASSIFIED" just on top of every page.