Hey guys, so I'm running a website that has a comment box.
For some reason, when someone has a comment which contains an apostrophe, it does not go through.
Anyone know what i need to do to fix this issue? Its a PHP comment box that saves everything to an SQL database.
Here is the code for the form:
Code:
<script>
function commentSubmit(){
if(form1.name.value == '' && form1.comments.value == ''){ //exit if one of the field is blank
alert('Please type your confession');
return;
}
var name = form1.name.value;
var comments = form1.comments.value;
var xmlhttp = new XMLHttpRequest(); //http request instance
xmlhttp.onreadystatechange = function(){ //display the content of insert.php once successfully loaded
if(xmlhttp.readyState==4&&xmlhttp.status==200){
document.getElementById('comment_logs').innerHTML = xmlhttp.responseText; //the chatlogs from the db wi$
}
}
xmlhttp.open('GET', 'insert.php?comments='+comments, true); //open and send http request
xmlhttp.send();
}
$(document).ready(function(e) {
$.ajaxSetup({cache:false});
setInterval(function() {$('#comment_logs').load('logs.php');}, 2000);
});
</script>