This was resolved I am using $cleanName = addslashes($name); to put a slash in the name field where an apostrophe would be. However, when I try to use $cleanComment = addslashes($comment); it does not work but instead duplicates the item -- one without the apostrophe and one with the apostrophe. MySQL doesn't accept apostrophes. I am not sure why it is not working, can anyone point me in the right direction?
I also have this in the form code
document.getElementById('name').onkeypress = function () {
if (event.keyCode === 39) { // apostrophe
// prevent the keypress
return false;
}
};
This is the PHP Code
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$confirm = $_POST['confirm'];
$cleanName = addslashes($name);
$cleanComment = addslashes($comment);
$sql = "INSERT INTO contact (name, email, commtype, comment, confirm)
VALUES ('$cleanName', '$_POST[email]', '$_POST[commtype]','$_POST
[comment]','$cleanComment')";
Thank you for your help.