Hi everyone! My name's Tom and I'm new here! I'm also fairly new to PHP.
I have a page for editing content with a WYSIWYG editor (TinyMCE). Content is entered into the text box of the WYSIWYG editor and then the "Update" button is pressed. It is supposed to then take the content entered and update the database. Here's the trouble. When the user clicks "Update", it just goes to update.php and sits there. It doesn't do anything! update.php is supposed to kick me a mysqli_error if it has problems connecting or querying the database, but I just get a blank page! It's not even redirecting me back to the CMS and no changes are made to the database at all!
Here's my form:
<?php
if(isset($_GET['message'])) {
echo "<p><font color='red'>Update Successful</font></p>";
}
require("../sources/connection.php");
$page = (isset($_GET['page'])) ? $_GET['page'] : "1";
$sql = "SELECT id, title, content FROM pages WHERE id='$page'";
$result = $conn->query($sql) or die(mysqli_error() );
if($result) {
$row = $result->fetch_object();
echo '<form method="post" action="update.php">';
echo '<input type="hidden" name="id" value="' . $row->id . '" />';
echo '<input type="text" name="title" value="' . $row->title . '" />';
echo '<textarea name="content" cols="50" rows="15">';
echo $row->content;
echo '</textarea>';
echo '<input type="submit" name="editContent" value="Submit" />';
echo '</form>';
}
?>
Here's what update.php looks like:
<?php
if (isset($_POST['editConent'])) {
require("../sources/connection.php");
$content = $_POST['content'];
$id = $_POST['id'];
$sql = "UPDATE pages SET content='$content' WHERE id='$id'";
$result = $conn->query($sql) or die(mysqli_error());
if($result) {
header("location: index.php?message=1");
}
}
?>
What am I missing here? Any suggestions or help would be greatly appreciated!!