People can now view pastes!

This commit is contained in:
pikami 2016-06-09 09:02:09 +00:00
parent d1019f8df6
commit 31ae9de368
2 changed files with 16 additions and 3 deletions

13
ViewPaste.php Normal file
View File

@ -0,0 +1,13 @@
<div class="panel panel-default">
<div class="panel-body">
<?php
if(isset($id)){
include "config/config.php";
$stmt = $conn->query('SELECT * FROM pastes WHERE id='.$id);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<h1>".$result["title"]."</h1>";
echo "<textarea class=\"form-control\" rows=\"5\" disabled=\"true\">".$result["text"]."</textarea>";
} else echo "Error: id not set";
?>
</div>
</div>

View File

@ -1,10 +1,8 @@
<?php
include "config/config.php";
if(isset($_POST["type"])){
echo "TYPE!";
//===New_Paste===//
if($_POST["type"]=="paste" && isset($_POST["text"])){
echo "TEXT!";
/* Set paste details */
$title = "Untitled";
$text = $_POST["text"];
@ -16,9 +14,11 @@ if(isset($_POST["type"])){
$stmt->bindParam(':tit', $title);
$stmt->bindParam(':txt', $text);
$stmt->execute();
$id = $conn->lastInsertId();
$conn = null; //close connection to database
header("Location: ".$id);
die();
}
}
echo "FIN!";
$conn = null;
?>