People can now post pastes!

This commit is contained in:
pikami 2016-06-09 08:22:48 +00:00
parent 7291bdc056
commit d1019f8df6
4 changed files with 49 additions and 3 deletions

View File

@ -1,14 +1,15 @@
<div class="panel panel-default">
<div class="panel-body">
<form role="form">
<form role="form" method="post" action="post.php" onsubmit="document.getElementById('submit').disabled=true;document.getElementById('submit').value='Please wait...';">
<div class="form-group">
<label for="title">Paste title:</label>
<input type="title" class="form-control" id="title">
<input type="title" class="form-control" id="title" name="title">
</div>
<div class="form-group">
<label for="text">New paste:</label>
<textarea class="form-control" rows="5" id="text"></textarea>
<textarea class="form-control" rows="5" id="text" name="text"></textarea>
</div>
<input type='hidden' name='type' value='paste'></input>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>

18
config/config.php Normal file
View File

@ -0,0 +1,18 @@
<?php
//========SQL_CONFIG========//
$SQL_Host = "localhost";
$SQL_Database = "palm-paste";
$SQL_User = "paste";
$SQL_Password = "ckQgRJRhib74XMgVpzmn38uj1MrCcNnK7L9bc7zu";
//========CONNECTION========//
$conn = new PDO('mysql:host='.$SQL_Host.';dbname='.$SQL_Database.';charset=utf8mb4', $SQL_User, $SQL_Password);
/*
//==========INSERT==========//
$stmt = $dbh->prepare("INSERT INTO Customers (CustomerName,Address,City)
VALUES (:nam, :add, :cit)");
$stmt->bindParam(':nam', $txtNam);
$stmt->bindParam(':add', $txtAdd);
$stmt->bindParam(':cit', $txtCit);
$stmt->execute();
*/
?>

View File

@ -31,6 +31,9 @@
if (isset($_GET["page"])){
if($_GET["page"] == "create"){
include "NewPaste.php";
} else if (is_numeric($_GET["page"])) {
$id = $_GET["page"];
include "ViewPaste.php";
} else {
echo "The page does not exist";
}

24
post.php Normal file
View File

@ -0,0 +1,24 @@
<?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"];
if(isset($_POST["title"]))
$title = $_POST["title"];
/* Add paste to database */
$stmt = $conn->prepare("INSERT INTO pastes (title,text)
VALUES (:tit, :txt)");
$stmt->bindParam(':tit', $title);
$stmt->bindParam(':txt', $text);
$stmt->execute();
$conn = null; //close connection to database
}
}
echo "FIN!";
$conn = null;
?>