Hello,
I could really use your help!!
I have created a CMS system which works as intended apart from one aspect, the FCK editor...
I code in PHP and the only thing I am struggling with, is actually getting the PHP to INSERT and UPDATE table data whilst using FCK editor. When using a standard text box I encounter no problems what so ever. However when using FCK editor, my scripts don't function.
Why is this? Am I doing something wrong.... Below is the scripts.
Edit Page PHP (UPDATE RECORDS)
<? /* Include Configuration Files */ include_once "../config/config.php"; //Edit Page $edit = $_GET["edit"]; if("yes" == $edit) { /* Update Page within database. */ $year = date('Y'); $month = date('m'); $day = date('d'); $con = mysql_connect("$server","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); $id = $_POST["id"]; $title1 = $_POST["title"]; $content1 = $_POST["website_content"]; $visible = $_POST["visible"]; mysql_query("UPDATE ap_pages SET title = '$title1' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET content = '$content1' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET dateedit = '$year-$month-$day' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET visible = '$visible' WHERE id LIKE '$id'"); mysql_close($con); echo '<div class="alertsuccess_info"> <strong>Page Modified Successfully</strong> - Your changes have taken effect immeadiately. </div>'; echo "<meta http-equiv='refresh' content='3;url=index.php?ToDo=WebsiteContent/ViewPages' />"; } if("yes" != $edit) { $con = mysql_connect("$server","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); $pageid = $_GET["id"]; $result = mysql_query("SELECT * FROM ap_pages WHERE id = '$pageid'"); while($row = mysql_fetch_array($result)) { $id = $row['id']; $title1 = $row['title']; $content = $row['content']; $date = $row['date']; $date1 = $row['dateedit']; $visible = $row['visible']; } } ?>
New Page PHP script
<? /* Include Configuration Files */ include_once "../config/config.php"; /* Retrieve META Data From Database */ //Add Page $save = $_GET["save"]; if("yes" == $save) { /* Update Page Information throughout database. */ $title = $_POST["title"]; $website_content = $_POST["website_content"]; $year = date('Y'); $month = date('m'); $day = date('d'); $date2 = $year-$month-$date; $visible = $_POST["visible"]; mysql_connect($server, $dbuser, $dbpass) or die ("Could not connect to mysql because ".mysql_error()); mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $query = mysql_query("SELECT * FROM ap_pages WHERE title LIKE '$title'"); $num_rows = mysql_num_rows($query); if(empty($title) || empty($content) || empty($visible)) { echo "<div class='alerterror_info'> <strong>Please Complete All Fields</strong> - $fname, Please complete all of the fields inorder to add this page successfully. </div>"; $title1 = $_POST["title"]; $website_content_one = $_POST["website_content"]; } elseif('0' == $num_rows) { mysql_query("INSERT INTO ap_pages (title, content, date, dateedit, visible) VALUES ('$title', '$website_content', '$year-$month-$day', '$year-$month-$day', '$visible')"); echo "<div class='alertsuccess_info'><strong>Page Added Successfully</strong> - This page has been added successfully. You selected $visible for visibility. Forwarding to page listings in 3 seconds.</div>"; echo '<meta http-equiv="refresh" content="3;url=index.php?ToDo=WebsiteContent/ViewPages" />'; } else { echo '<meta http-equiv="refresh" content="0;url=index.php?ToDo=WebsiteContent/ViewPages&error=yes1" />'; } } ?>
any ideas?
I can provide the HTML pages too if you wish... I really need this to work, as my client gets really angry, I'm sure you know what type of client I am talking about.
Many Thanks In Advance!!!!
Re: I really need your help!!! :( - MY FCKeditor wont work
Re: I really need your help!!! :( - MY FCKeditor wont work
Can you explain this a bit more clearly? When does it fail - on editor page load, during editing, on submit? What is the nature of the failure? Do you get error codes?
I have a small CMS that I've just updated to use FCK and it was generally a breeze. my first reaction to what you've described is to note that FCK is only going to effect what is going on on the client (browser) end of things. Once the user submits the form, PHP deals with the output in the same way that it does the output of a textfield. If your code works with a textfield, it should work just the same with the output of an editor.
Here are a couple of things that you need to pay attention to:
1) does your code work WITHOUT fck?
2) how are you handling the data on the server side? (encoding, etc.)
Read the docs! it helps ... I've learned that the hard way!