Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2. include('connection.php');
  3. include('restrict-login.php');
  4.  
  5. if(isset($_POST['comments'])) {
  6.  
  7. $query = $dbh->prepare('INSERT into comments (user, report, body) VALUES (?, ?, ?)');
  8. $query->execute(array($_SESSION['id'], $_POST['report'], $_POST['body']));
  9.  
  10. } elseif(isset($_GET['id'])) {
  11.  
  12. $query = $dbh->prepare('SELECT * FROM reports WHERE id = ?');
  13. $qyuery->execute(array($_GET['id']));
  14. $report = $query->fetchAll();
  15.  
  16. if(!$report) die('Report not found!');
  17.  
  18. $query = $dbh->prepare('SELECT * FROM comments where report = ?');
  19. $query->execute(array($_GET['id']));
  20. $commetns = $query->fetchAll();
  21.  
  22. ?><!DOCTYPE html>
  23. <html>
  24. <head>
  25. <title>reports</title>
  26. </head>
  27. <body>
  28. <div>
  29. <?php echo $report['user'], $report['doctor'], $report['timestamp'], $report['speciality'], $report['appointment'], $report['treatment']; ?>
  30. </div>
  31. <h2>Comments</h2>
  32. <?php foreach($comments as $row) { ?>
  33. <div>
  34. <?php echo $row['user'], $row['report'], $row['body'], $row['timestamp'] ?>
  35. </div>
  36. <?php } ?>
  37. <form action="" method="POST">
  38. <textarea name="body"></textarea>
  39. <input type="hidden" name="report" value="<?php echo $report['id']; ?>">
  40. <input type="submit"></input>
  41. </form>
  42. </body>
  43. </html>
  44. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement