How can I add my values owdid and visited id after clicking below link by ajax?
<a href="index.php" onclick="insertvisit(<?php echo $interestid;?>)">member1</a>
Below is my insertvisit function. I have defined owdid and interestid
function insertvisit(visitedid) {
$.ajax({
type: "POST",
url: 'insertvisit.php',
data:{'field1' : owdid, 'field2' : visitedid},
success:function(html) {
}
});
}
and below is insertvisit.php
global $pdo;
$ownid = $_GET['field1'];
$interestid =$_GET['field2'];
$query = $pdo->prepare("UPDATE tablem SET field1= ? WHERE field2= ?");
$query -> bindValue(1, $ownid);
$query -> bindValue(2, $interestid);
$query -> execute();
Please help thanks.
Aucun commentaire:
Enregistrer un commentaire