I have problem that Jquery Post is not sending data to other page. Data is sent to LikeMail.php page by clicking image. Date is stored in the id of the image.
<a href="viewProfile.php?id=<?php echo $record['user_id']; ?>"><img class="img-rounded" id="<?php echo $record['user_id']; ?>" src=" <?php echo "../shadi/images/" . $record['user_photo1'] ?>" alt=""
width="70%" height="20%"> </a>
This is my LikeMail.php page
<?php
session_start();
?>
<html>
<head>
<script src="jquery-1.12.2.min.js"></script>
<script src="test.js"></script>
</head>
</html>
<?php
include("db.php");
if(!isset($_SESSION['login'])) {
echo "";
}
else {
$user1 = $_SESSION['user_id'];
// echo $user1;
if(isset($_POST['fname'])) {//This is being received from jquery
$user2 = $_POST['fname'];
//$lname = $_POST['surname'];
//echo $lname;
/*$sql = "UPDATE notification SET alert='$fname' WHERE id = '1'";
if(mysqli_query($conn,$sql))
echo "updated";*/
$check_for_likes = mysqli_query($conn, "SELECT * FROM liked WHERE user1='$user1' AND user2='$user2'");
$numrows_likes = mysqli_num_rows($check_for_likes);
if (false == $numrows_likes) {
echo mysqli_error($conn);
}
if ($numrows_likes >= 1) {
echo '<input type="submit" name="unlikebutton_' . '" value="Unlike" id="Unlike" class="btn btn-lg btn-info edit">';
}
if ($numrows_likes == 0) {
echo '<input type="submit" name="likebutton_' . '" value="Like" id="Like" class="btn btn-lg btn-info edit">';
}
}
}?>
POST array with variable fname (Also mentioned in the comments in the code) is being received from the previous page.
This is jquery method
$(document).ready(function(){
$('.img-rounded').click(function(){
$.post("LikeMail.php",
{fname: this.id},
function(data){
$('.respond').html(data);
}
);
});
});
Can you please tell me that what is the bug there. I have run this jquery method on other page other than LikeMail.php and it runs perfectly but Jquery post is not sending data to LikeMail.php