Advertisement
Z645

home.php

May 18th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['body'])){
  4. $body = strip_tags($_POST['body']);
  5.     if (strlen($_POST['body'] > 250)){
  6.         $errors[] = 'Max character length is 250.';
  7.     }
  8.     if (empty($_POST['body']) === true){
  9.         $errors[] = 'Status cannot be empty.';
  10.     }
  11.     if (empty($errors) === true){
  12.         mysql_query("INSERT INTO `feeds` (user_id, username, body, date) VALUES ('$session_user_id', '" . $user_data['username'] . "', '$body', NOW())");
  13.     }
  14. }
  15. ?>
  16.  
  17. <div class="status">
  18.     <form action="" method="POST">
  19.         <input type="text" name="body" id="body" class="post_status" placeholder="What are you up to this fine day?">
  20.         <input type="submit" class="post_button" name="submit" value="Post">
  21.     </form>
  22.     <div class="feeds">
  23.     <?php
  24.     if (empty($errors) !== true){
  25.         echo output_errors($errors);
  26.     }
  27.         $getquery = mysql_query("SELECT * FROM `feeds` ORDER BY `DATE` DESC LIMIT 0, 10");
  28.         while($rows = mysql_fetch_assoc($getquery)){
  29.             $id = $rows['id'];
  30.             $user_id = $rows['user_id'];
  31.             $username = $rows['username'];
  32.             $body = $rows['body'];
  33.             $date = $rows['date'];
  34.             $dellink = "| <a href=\"http://localhost/vibeate/wigets/deletepost.php?id=" . $id . "\" style='color: grey;text-decoration:none;'>Delete</a>";
  35.  
  36.             ?>
  37.             <h2><a href="users/<?php echo $username; ?>"><?php echo $username; ?></a></h2>
  38.             <p><?php echo $body; ?></p><br />
  39.             Posted on <?php echo $date; ?> <?php if ($user_id == $user_data['user_id'] || is_admin($user_data['user_id']) === true){
  40.                 echo $dellink;
  41.             }
  42.             ?>
  43.             <br /><hr width="500px">
  44.             <?php
  45.             }
  46.             if (empty($id)){
  47.                 echo '<h3>There\'s no posts to show...Be the first to post</h3>';
  48.             }
  49.             ?>
  50.     </div>
  51. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement