Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <div class="panel panel-default">
  2. <div class="panel-heading"><h4>My Messages</h4></div>
  3. <div class="panel-body">
  4. <h4 style='text-decoration: underline; color:#000'>Messages:</h4>
  5.  
  6. <script>
  7.  
  8. ????
  9.  
  10. </script
  11.  
  12.  
  13.  
  14. <?php include_once('pm/pm_open.php'); ?>
  15. </div><!--/panel-body-->
  16. </div><!--/panel-->
  17.  
  18. <?php
  19. $usid = $_SESSION['user_id'];
  20.  
  21. $dbh = new PDO('mysql:host=127.0.0.1;dbname=login','root','');
  22. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  23.  
  24. $sql="SELECT * FROM `pm` WHERE `user1` = :user1 or `user2` = :user2 ORDER BY time ASC ";
  25. $stmt=$dbh->prepare($sql);
  26. $stmt->bindValue(':user1', $usid, PDO::PARAM_INT);
  27. $stmt->bindValue(':user2', $from, PDO::PARAM_INT);
  28. $stmt->execute();
  29. if ($stmt->rowCount() > 0) {
  30. $result = $stmt->fetchAll();
  31. }
  32. foreach( $result as $row) {
  33. $post_id = $row['id'];
  34. $from = $row['user2'];
  35. $to = $_row['user1'];
  36. $time = $row['time'];
  37. $message = $row['message'];
  38.  
  39. echo "<br /><div style='background-color:black; color:white'><p style='width:70%; margin:auto'>From: <a href='profile.php?id=".$from."'>User #".$from."</a><br />".$message." <br /> @ ".$time."<br /></p>
  40. <form>
  41. <input type='button' id='delete' class='btn-xs btn-danger' value='Delete'>
  42. </form>
  43. </div>";
  44.  
  45. }
  46.  
  47. if(isset($_POST['delete'])){
  48.  
  49.  
  50. $STH = $dbh->prepare("DELETE FROM pm WHERE id = :id");
  51. $STH->bindParam(':id', $post_id);
  52. $STH->execute();
  53.  
  54.  
  55. echo "<br ><p style='background-color:black; text-align:center; color:Red'>Message Deleted Successfully<p>";
  56. }
  57.  
  58. <script>
  59. var _delete = document.getElementById("delete");
  60. _delete.onClick=function(){
  61. ????
  62. };
  63. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement