I need help to stupid- (and hack-) proof my database inputs.
What I have is an image-gallery in a table, (im_id, im_title, im_description, im_filename etc...) I've modified it from an image-gallery tutorial online, however, I fear the tutorial was not very thorough. As I get more familiar with the code, I can tell it's definitely missing the required security, but I'm not sure what.
Image info is added to the database via a form (method="post"):
<textarea name="txtTitle" cols="50" rows="5" id="txtTitle">
if the form ISSET, then:
$imgTitle = $_POST['txtTitle'];
and then finally, the table is updated with no further data manipulation:
$sql = "INSERT INTO tbl_image (im_title) VALUES ('$imgTitle')";
Later, the data is output as such:
<?php echo $image['im_title']; ?>
<?php echo htmlspecialchars($image['im_description']); ?>
Why would they use htmlspecialchars only on the im_description field and not on the title field (both are text?). Is this something that all output fields should be wrapped in?
And... the code chokes on apostrophe's, how do I fix that?