Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('connection.php');
- include('restrict-login.php');
- if(isset($_POST['comments'])) {
- $query = $dbh->prepare('INSERT into comments (user, report, body) VALUES (?, ?, ?)');
- $query->execute(array($_SESSION['id'], $_POST['report'], $_POST['body']));
- } elseif(isset($_GET['id'])) {
- $query = $dbh->prepare('SELECT * FROM reports WHERE id = ?');
- $qyuery->execute(array($_GET['id']));
- $report = $query->fetchAll();
- if(!$report) die('Report not found!');
- $query = $dbh->prepare('SELECT * FROM comments where report = ?');
- $query->execute(array($_GET['id']));
- $commetns = $query->fetchAll();
- ?><!DOCTYPE html>
- <html>
- <head>
- <title>reports</title>
- </head>
- <body>
- <div>
- <?php echo $report['user'], $report['doctor'], $report['timestamp'], $report['speciality'], $report['appointment'], $report['treatment']; ?>
- </div>
- <h2>Comments</h2>
- <?php foreach($comments as $row) { ?>
- <div>
- <?php echo $row['user'], $row['report'], $row['body'], $row['timestamp'] ?>
- </div>
- <?php } ?>
- <form action="" method="POST">
- <textarea name="body"></textarea>
- <input type="hidden" name="report" value="<?php echo $report['id']; ?>">
- <input type="submit"></input>
- </form>
- </body>
- </html>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement