Created
November 23, 2014 21:28
-
-
Save samroar/58f8fb8c07851e5048be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('connection.php'); | |
include('restrict-login.php'); | |
if(isset($_POST['body'])) { | |
$query = $dbh->prepare('INSERT into comments (user, report, body) VALUES (?, ?, ?)'); | |
$query->execute(array($_SESSION['id'], $_POST['report'], $_POST['body'])); | |
header('location : reports.php?id='.$_POST['report']); | |
} elseif(isset($_GET['id'])) { | |
$query = $dbh->prepare('SELECT * FROM reports WHERE id = ?'); | |
$query->execute(array($_GET['id'])); | |
$report = $query->fetchAll(); | |
if(!$report) die('Report not found!'); | |
$report = $report[0]; | |
$query = $dbh->prepare('SELECT * FROM comments where report = ?'); | |
$query->execute(array($_GET['id'])); | |
$comments = $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 } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment