Hi all,
I'm currently building a cms for a client and decided to use fckeditor in the cms pages. The site is php and uses a mysql database. I've got static pages which fck works fine (I can edit/update these no problem). Where I'm experiencing problems is with the news pages which are created dynamically (ids auto increment in the database). I can call in the details from the database but when I update them they simply won't update. I've messed around with the code so much now that I don't know where to go and this page no longer works. If someone could have a look at this and see if there is anything obvious or point me in the right direction I would be grateful.
Thanks
<?php session_start(); // is the one accessing this page logged in or not? if ($_SESSION['logged'] != 1) { // There was no session found! header("Location: index.php"); // Goes to login page. exit(); // Stops the rest of the script. } ?> <?php include '../common/config.php'; include '../common/opendb.php'; include_once "../includes/tools/fckeditor/fckeditor.php"; if ($_POST['submit_form'] == 1) { // Save to the database. $title = mysql_real_escape_string(trim($_POST['fcktext1'])); $result = mysql_query("UPDATE NEWS SET title = '".$title."' WHERE `id` = " . $_GET["id"]); if (!$result) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: tdf_edit_news.php?=&id='{$_GET['id']}'"); } if ($_POST['submit_form'] == 2) { // Save to the database. $teaser = mysql_real_escape_string(trim($_POST['fcktext2'])); $result = mysql_query("UPDATE NEWS SET teaser = '".$teaser."' WHERE `id` = " . $_GET["id"]); if (!$result) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: tdf_edit_news.php?=&id='{$_GET['id']}'"); } if ($_POST['submit_form'] == 3) { // Save to the database. $photo = mysql_real_escape_string(trim($_POST['fcktext3'])); $result = mysql_query("UPDATE NEWS SET photo = '".$photo."' WHERE `id` = " . $_GET["id"]); if (!$result) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: tdf_edit_news.php?=&id=''{$_GET['id']}'"); } if ($_POST['submit_form'] == 4) { // Save to the database. $content = mysql_real_escape_string(trim($_POST['fcktext4'])); $result = mysql_query("UPDATE NEWS SET content = '".$content."' WHERE `id` = " . $_GET["id"]); if (!$result) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: tdf_edit_news.php?=&id='{$_GET['id']}'"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Website Administration</title> <link href="css/admin.css" rel="stylesheet" type="text/css" /> </head> <body> <?php $q = "SELECT id, title, teaser, photo, content " . "FROM NEWS " . "WHERE id = '{$_GET['id']}'"; $result = mysql_query($q) or die ("Could not execute query : $q." . mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $title= $row["title"]; $teaser= $row["teaser"]; $photo= $row["photo"]; $content= $row["content"]; } ?> <div align="center"> </div> <table width="790" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" valign="top"> <?php include 'common/tdf_admin_header.php'; ?> </td> </tr> <tr> <td width="200" valign="top" bgcolor="#ED008C"> <?php include 'common/tdf_admin_menu.php'; ?> </td> <td width="590" valign="top" bgcolor="#CCCCCC"><table width="570" border="0" align="right" cellpadding="10" cellspacing="0"> <tr> <td colspan="2" valign="top"> </td> </tr> <tr> <td colspan="2" valign="top" class="table_captions">Lets Support - Content Management System </td> </tr> <tr> <td colspan="2" valign="top"><span class="table_text">Edit News Page</span></td> </tr> <tr> <td width="69" valign="top"><span class="table_captions">Title:</span></td> <td width="431" valign="top"> <form action="tdf_edit_news.php" method="post"> <?php // Get data from the database $q = mysql_query("SELECT title FROM NEWS WHERE `id` = " . "$_GET['id']"); $data = mysql_fetch_array($q); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext1'); $oFCKeditor->ToolbarSet = 'Title'; $oFCKeditor->BasePath = "../includes/tools/fckeditor/"; $oFCKeditor->Value = $data["title"]; $oFCKeditor->Width = 420; $oFCKeditor->Height = 80; echo $oFCKeditor->Create(); ?> <br /> <br /> <input type="hidden" name="submit_form" value="1" /> <input type="submit" value="Update Title" /> </form></td> </tr> <tr> <td valign="top"><span class="table_captions">Teaser:</span><br /></td> <td valign="top"> <form action="tdf_edit_news.php" method="post"> <?php // Get data from the database $q = mysql_query("SELECT teaser FROM NEWS WHERE `id` = " . "$_GET['id']"); $data = mysql_fetch_array($q); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext2'); $oFCKeditor->ToolbarSet = 'Basic'; $oFCKeditor->BasePath = "../includes/tools/fckeditor/"; $oFCKeditor->Value = $data["teaser"]; $oFCKeditor->Width = 420; $oFCKeditor->Height = 120; echo $oFCKeditor->Create(); ?> <br /> <br /> <input type="hidden" name="submit_form" value="2" /> <input type="submit" value="Update Teaser" /> </form></td> </tr> <tr> <td valign="top"><span class="table_captions">Photo:</span><br /></td> <td valign="top"> <form action="tdf_edit_news.php" method="post"> <?php // Get data from the database $q = mysql_query("SELECT photo FROM NEWS WHERE `id` = " . "$_GET['id']"); $data = mysql_fetch_array($q); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext3'); $oFCKeditor->ToolbarSet = 'Basic'; $oFCKeditor->BasePath = "../includes/tools/fckeditor/"; $oFCKeditor->Value = $data["photo"]; $oFCKeditor->Width = 420; $oFCKeditor->Height = 120; echo $oFCKeditor->Create(); ?> <br /> <br /> <input type="hidden" name="submit_form" value="3" /> <input type="submit" value="Update Photo" /> </form></td> </tr> <tr> <td valign="top"><span class="table_captions">Content:</span><br /></td> <td valign="top"> <form action="tdf_edit_news.php" method="post"> <?php // Get data from the database $q = mysql_query("SELECT content FROM NEWS WHERE `id` = " . "$_GET['id']"); $data = mysql_fetch_array($q); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext4'); $oFCKeditor->ToolbarSet = 'Basic'; $oFCKeditor->BasePath = "../includes/tools/fckeditor/"; $oFCKeditor->Value = $data["content"]; $oFCKeditor->Width = 420; $oFCKeditor->Height = 350; echo $oFCKeditor->Create(); ?> <br /> <br /> <input type="hidden" name="submit_form" value="4" /> <input type="submit" value="Update Content" /> </form></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> </tr> </table></td> </tr> <tr> <td colspan="2"> <?php include 'common/tdf_admin_footer.php'; ?> </td> </tr> </table> <?php include '../common/closedb.php'; ?> </body> </html>