php
<?php
include 'connection.php';
echo "reached page";
$stmt = $conn->prepare("INSERT INTO flagged ( ID,URL,COUNT,comment)VALUES ( :id, :url, :count,:COMMENT )");
$stmt->bindParam(':id', $id);
$stmt->bindParam(':url', $url);
$stmt->bindParam(':count', $count);
$stmt->bindParam(':COMMENT', $comment);
$id = NULL;
$url = $_POST['url']);
$count = 1;
$comment = $_POST['data']);
$stmt->execute();
?>
jquery
$(document).ready(function() {
$('#flagForm').submit(function(){
return false;
});
$('#flag').click(function(){
$('#comment').show();
});
$('body').on('click', '#commentSubmit', function(e) {
$.post('flag.php',
{
data:$('#comment').val(),
url:(window.location)
},
function(response){
alert(response);
});
});
});
html
<div id='comment'><h1 ></h1>
<form id="flagForm" action="flag.php" method="post">
<textarea id='commentData' placeholder='whats the problem' ></textarea>
<input type="submit" id='commentSubmit' />
</form>
</div>
I can’t seem to get my post to reach my php page. I have never had this problem before. The object is to flag a page by users. I have another post method and php page in using the same connection so that can’t be it. Any help would be appreciated. And there is more to the jquery and html but this is all that is relative to the problem.
#commentis a div, you have to call.val()on the input/textarea with the dataI see you get an illegal invocation error here
url:(window.location)usewindow.location.hrefinstead .window.locationis an object that jQuery cant serialize so you get that error.