</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/8898108/php-logical-operators-precedence-affects-variable-assignment-results-strangely" dir="ltr">PHP Logical Operators precedence affects variable assignment results strangely</a>
<span class="question-originals-answer-count">
(3 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2014-05-25 13:41:48Z" class="relativetime">5 years ago</span>.</div>
</div>
</aside>
Plain and simple, this is what I am trying to create:
function addComment($post_id, $user_id, $comment) {
var post_id = $post_id;
var user_id = $user_id;
var comment = $comment;
var xhr;
if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
else xhr = new ActiveObject("Microsoft.XMLHTTP");
var url = 'commentcreate.php?post_id=' + post_id + '&user_id=' + user_id + '&comment=' + comment
xhr.open('GET', url, false);
xhr.onreadystatechange = function () {
if (xhr.readyState===4 && xhr.status===200) {
div.innerHTML = xhr.responseText;
}
}
xhr.send();
return false;
And then I got the PHP file which would be recieving these variables:
if(isset($_GET['post_id']) && isset($_GET['user_id']) && isset($_GET['comment'])) $post_id = $_GET['post_id'] && $user_id = $_GET['user_id'] && $comment = $_GET['comment'];
Which is code that is extremely hard to read that is meant as working like the following:
if (
isset($_GET['post_id'])
&& isset($_GET['user_id'])
&& isset($_GET['comment'])
) {
$post_id = $_GET['post_id'];
$user_id = $_GET['user_id'];
$comment = $_GET['comment'];
}
So basicly, I want a function that takes 3 variables, and sends them over to a php file where I can do my thing and add them to the database (to create a comment). But this does not work. It works with 1 variable, but I dont know how to get it to work with more then 1. Im guessing that its something wrong on the php side, but i could be wrong. Any suggestions?
</div>