Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Main{
- //fetching posts from database
- public function posts(){
- global $conn;
- $query = $conn->prepare("SELECT * FROM `posts`,`users` WHERE userId = user_id_p ORDER BY `post_id` DESC");
- $query->execute();
- return $query->fetchAll();
- }
- //add new post if user post
- public function add_post($user_id,$status,$file_parh){
- global $conn;
- if(empty($file_parh)){
- $file_parh = 'NULL';
- }
- $query = $conn->prepare('INSERT INTO `posts` (`post_id`, `user_id_p`, `status`, `status_image`, `status_time`) VALUES (NULL, ?, ?,?, CURRENT_TIMESTAMP)');
- $query->bindValue(1,$user_id);
- $query->bindValue(2,$status);
- $query->bindValue(3,$file_parh);
- $query->execute();
- header('Location: home.php?id='.$_POST['email']);
- }
- //fetch user data by user id
- public function user_data($user_id){
- global $conn;
- $query = $conn->prepare('SELECT * FROM users WHERE userId = ?');
- //Line 28 below
- $query->bindvalue(1,$user_id);
- $query->execute();
- return $query->fetch();
- }
- ?>
Add Comment
Please, Sign In to add comment