Commit cc4aca43 authored by Ryan Wade's avatar Ryan Wade

file was in wrong feature branch.

parent d6f13967
<?php
include "./SQL.php";
session_start();
if(false && !$_SESSION['isAuthenticated'])
{
header('Location: login.html');
die();
}
else
{
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset($_POST['id']) and isset($_POST['title']) and isset($_POST['desc']))
{
$host = "localhost";
$username = "root";
$pass = "root";
$database = "website";
$conn = new mysqli($host, $username, $pass, $database);
if($conn->connect_error)
{
die();
}
$sql = "INSERT INTO pages VALUES (".
$_POST['id'].", ".
$_POST['pid'].", ".
"'".$_POST['title']."', ".
"'".$_POST['desc']."', ".
"'".$_POST['image']."', ".
"'".$_POST['content']."', ".
$_POST['publish'].") ON DUPLICATE KEY UPDATE ".
"pid = ".$_POST['pid'].", ".
"title = '".$_POST['title']."', ".
"description = '".$_POST['desc']."', ".
"image = '".$_POST['image']."', ".
"content = '".$_POST['content']."', ".
"publish = ".$_POST['publish'].";";
$conn->query($sql);
$conn->commit();
}
echo $_POST['content'];
die();
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252">
<title>Edit Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<table><tr><td>
<div id="form">
<table>
<?php
$sql = new SQL();
if(!isset($_GET['id']))
{
$_GET['id'] = 0;
}
$page = $sql->GET_TABLE(0)->GET_ROW($_GET['id'])->data;
echo "<tr><td>Page Id</td><td><input type=\"number\" id=\"id\" value=\"".$page[0]."\"></input></td></tr>\n";
echo "<tr><td>Parent Id</td><td><input type=\"number\" id=\"pid\" value=\"".$page[1]."\"></input></td></tr>\n";
echo "<tr><td>Title</td><td><input type=\"text\" id=\"title\" value=\"".$page[2]."\"></input></td></tr>\n";
echo "<tr><td>Description</td><td><input type=\"text\" id=\"desc\" value=\"".$page[3]."\"></input></td></tr>\n";
echo "<tr><td>Image</td><td><input type=\"text\" id=\"image\" value=\"".$page[4]."\"></input></td></tr>\n";
echo "<tr><td>Content</td><td><textarea id=\"content\">".$page[5]."</textarea></td></tr>\n";
echo "<tr><td>Publish?</td><td><input type=\"checkbox\"".($page[6]?" checked":"")."></td></tr>\n";
echo "<tr><td><button id=\"submit\">Save</button></td></tr>\n";
?>
</table>
<script>
$("#submit").click(function(){
$.post("editPage.php",
{
id: $("#id").val(),
pid: $("#pid").val(),
title: $("#title").val(),
desc: $("#desc").val(),
image: $("#image").val(),
content: $("#content").val(),
publish: $("#publish").is(":checked")
},
function(data,status){
$("#preview").html(data);
});
});
</script>
</div>
</td>
<td style="vertical-align: top;">
<div id="preview">
</div>
</td></tr></table>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment