Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action = 'index.php?page=addLike' method = 'POST'>
- <input type = 'hidden' name = 'post_id' value = '$post_id'/>
- <input type = 'hidden' name = 'user_id' value = '$user_id'/>
- <input type = 'submit' value = '' class = 'likeButton'/>
- </form>";
- <?php
- include_once "models/blogLikes_Table.class.php";
- $like = new blogLikes_Table($db);
- $user_id = $siteVisitor->getId();
- $post_id = $_POST['post_id'];
- $like->insertLike($user_id, $post_id);
- public function insertLike($user_id, $post_id){
- $sql = "INSERT INTO blogLikes (user_id, post_id, value) VALUES ( ?,?,? )";
- $statement = $this->db->prepare($sql);
- $data = array($user_id, $post_id, "1");
- $statement->execute($data);
- return $statement;
- }
- $(".likeButton").click(function myCall() {
- var request = $.ajax({
- url: "addLike.php",
- type: "GET" ,
- data: "html"
- });
- request.done(function(msg) {
- alert("this works!!!!!");
- });
- request.fail(function(jqXHR, textStatus) {
- alert( "Request failed: " + textStatus );
- });
- return false;
- });
- var postData = $("#your_form_id").serializeArray();
- var request = $.ajax({
- url : "addLike.php",
- type: "POST",
- data : postData
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement