Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function uploadPost($title,$image){
- try{
- if(isset($_SESSION['user_session'])){
- $user_id = $_SESSION['user_session'];
- $stmt = $this->runQuery("SELECT * FROM users WHERE id=:id");
- $stmt->execute(array(":id"=>$user_id));
- $myRow=$stmt->fetch(PDO::FETCH_ASSOC);
- }else{
- $_SESSION["error"]='<div class="alert alert-danger alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>Sorry, You have to login in your profile!</div>';
- echo $_SESSION["error"];
- exit();
- }
- $addedby = $myRow['id'];
- $stmt = $this->conn->prepare("INSERT INTO fun_posts(title,image,addedby) VALUES(:title, :image, :addedby)");
- $stmt->bindparam(":title", $title);
- $stmt->bindparam(":image", $image);
- $stmt->bindparam(":addedby", $addedby);
- $stmt->execute();
- $_SESSION["result"]='<div class="alert alert-success alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>You have succesfully uploaded new post!</div>';
- echo $_SESSION["result"];
- exit();
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- }
- public function insertAction($action, $addedby, $follow, $unfollow, $comment, $reply, $likecomment,
- $likepost, $addimage, $addpost){
- try{
- $stmt = $this->conn->prepare("INSERT INTO user_actions(action,addedby,follow,unfollow,comment,reply,
- likecomment,likepost,addimage,addpost) VALUES(:action, :addedby, :follow, :unfollow, :comment, :reply,
- :likecomment, :likepost, :addimage, :addpost)");
- $stmt->bindparam(":action", $action);
- $stmt->bindparam(":addedby", $addedby);
- $stmt->bindparam(":follow", $follow);
- $stmt->bindparam(":unfollow", $unfollow);
- $stmt->bindparam(":comment", $comment);
- $stmt->bindparam(":reply", $reply);
- $stmt->bindparam(":likecomment", $likecomment);
- $stmt->bindparam(":likepost", $likepost);
- $stmt->bindparam(":addimage", $addimage);
- $stmt->bindparam(":addpost", $addpost);
- $stmt->execute();
- $_SESSION["result"]='<div class="alert alert-success alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>Action has been succesfully inserted!</div>';
- echo $_SESSION["result"];
- exit();
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement