Hello, I have a litle problem using FCKeditor for editing contents that is previous set by it.
I've created a table name:'statii', fields: 'ID', 'data' /CURDATE()/, 'htmlCode' /FCKeditor input content/ and freely inserting data. Had a bit of problem with the htmlstripslashes, so the code looks like this:
new_arche.php :
<form action="data_arch.php" method="post" target="_blank"> <?php $oFCKeditor = new FCKeditor('arche'); $oFCKeditor->BasePath = '/fckeditor/'; $oFCKeditor->Value = 'Въведете текста си тук'; $oFCKeditor->Create(); ?> <br /> <input type="submit" value="Submit"> </form>
data_arch.php:
<?php if ( isset( $_POST ) ) $postArray = &$_POST ; else $postArray = &$HTTP_POST_VARS ; foreach ( $postArray as $sForm => $value ) { if ( get_magic_quotes_gpc() ) $postedValue = stripslashes( $value ); else $postedValue = $value; } mysql_connect("localhost", $user, $pass) or die(mysql_error()); mysql_select_db("garmen_arche") or die(mysql_error()); mysql_query("INSERT INTO statii(htmlCode, data) VALUES('$postedValue', CURDATE())") or die(mysql_error()); echo "<br />"; echo $postedValue; ?> <?php //write mysql_connect("localhost", $user, $pass) or die(mysql_error()); mysql_select_db("garmen_arche") or die(mysql_error()); mysql_query("INSERT INTO accdate (curdata) VALUES(CURDATE())") or die(mysql_error()); ?>
that works fine, I can not code it for high securety stuff, so it is injection friendly for everyone
Here comes the sh** stuff, that I messed around with. I get the original text in the editor, but can't handle it from there. Can't use the new text in any way. When i set 'name' and 'value' on the hidden input, thats the value, that is displayed, if I use <?php ?> for a value, it shows as empty /no value/. So...:
edit_arche.php:
<form action="edit_arche.php" method="post"> <?php mysql_connect("localhost", $user, $pass) or die(mysql_error()); mysql_select_db("garmen_arche") or die(mysql_error()); if($_GET["cmd"] == "edit" || $_POST["cmd"] == "edit") { if (!isset($_POST["submit"])) { $ID = $_GET["rowID"]; $result = mysql_query("SELECT * FROM statii WHERE ID=$ID") or die(mysql_error()); $row = mysql_fetch_array($result); $rowhtmlCode = $row['htmlCode']; $oFCKeditor = new FCKeditor('edit_arche'); $oFCKeditor->BasePath = '/fckeditor/'; $oFCKeditor->Value = $rowhtmlCode ; $oFCKeditor->Create(); ?> <br /> <input type="hidden" value="Submit"> <input type="submit" name="submit" value="Submit"> </form> <?php echo $sForm; echo $value; } ?> <?php if ($_POST) $postArray = $_POST['edit_arche'] ; else $postArray = $HTTP_POST_VARS ; foreach ( $postArray as $sForm => $value ) { if ( get_magic_quotes_gpc() ) $postedValue = stripslashes( $value ); else $postedValue = $value; } echo $postedValue; echo "<br />"; echo $sForm; echo "<br />"; echo $value; mysql_connect("localhost", $user, $pass) or die(mysql_error()); mysql_select_db("garmen_arche") or die(mysql_error()); mysql_query("UPDATE statii SET htmlCode='$postedValue' WHERE id='$ID'") or die(mysql_error()); } ?>
Do you have any ideas, or what is YOUR method of editing with FCKeditor?
Greetings,
Krasi!
Re: UPDATE table using FCKeditor
nobody knows how to fix this bug or is it that simple and I can't see it... ?
I spend a week maybe two in search for an answer, but every time I trie something, another gets wrong. Programing is nice and peacefull job, that does good to the nervesystem
Re: UPDATE table using FCKeditor
Hi!
I have a similar problem, as far as I understood, since I am rather newbie to this stuff..
I use FCKEditor in my php page inside a form with some other INPUT fields..
When I submit the first time and write it into database, everything goes ok.
But now I added a corfirmation page to check if data is correct. If corrections are needed,
form data is sent back to previois page with
So far so good, BUT.. when there is some more complicated styles, other than
Using striplashes wont do me any good since I dont want to alter
bold or italic, eg. background color, the data (in $fckdata) goes bad.. If i try
to print it in confirmation page, "> tags appears whereever...
So:
INPUT PAGE -> WRITE TO SQL OK
INPUT PAGE -> CONFIRMATION PAGE -> WRITE TO SQL OK
INPUT PAGE -> CONFIRMATION PAGE -> INPUT PAGE -> CONFIRMATION PAGE with styles DONT WORK OK
I guess it has something to do with FORM-ENCODING or stuff that I dont really
understand
the data should the user think it is ok....