diff options
Diffstat (limited to 'report/edit.php')
-rw-r--r-- | report/edit.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/report/edit.php b/report/edit.php new file mode 100644 index 0000000..ef289bd --- /dev/null +++ b/report/edit.php @@ -0,0 +1,43 @@ +<?php +require '../config.php'; +require_once(TEMPLATES_PATH . "/header.php"); +require_once(TEMPLATES_PATH . "/panel.php"); +require_once(LIBRARY_PATH . "/functions.php"); + +if(!session_set()) { + header("Refresh: 2; URL={$config['urls']['base']}"); + goto footer; +} + +$id = isset($_GET['id']) ? $_GET['id'] : ""; +$title = ""; +$submitter = $_SESSION['user_name']; +$description = ""; + +if($id != "") { + $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']); + $query = $conn->prepare("SELECT title, description, users.username AS submitter FROM reports + JOIN users ON reports.author=users.id + WHERE reports.id=:report_id"); + $query->bindParam(':report_id', $id); + $query->execute(); + + $result = $query->fetch(); + $title = $result['title']; + $submitter = $result['submitter']; + $description = $result['description']; +} + +?> + +<form action="update.php?id=<?php echo $id; ?>" method="post"> +<input name="id" type="hidden" value="<?php echo $id; ?>"> +<p>Title: <input name="title" type="text" value="<?php echo $title; ?>"></p> +<p>Submitted by: <?php echo $submitter; ?></p> +<p>Description: <br><textarea name="description" rows=25 cols=80><?php echo $description; ?></textarea></p> +<input type="submit" value="submit" > +</form> + +<?php +footer: require_once(TEMPLATES_PATH . "/footer.php"); +?> |