0

I'm building a editable website for some people, I'm using ckeditor to let them be able to use WYSIWYG online, but when I'm using a post method to save the data, the code get messed up...

This is how I use ckeditor to save the tabs and all of my editable website:

<html>
<head>
<title>CKEditor Sample</title>
<script src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form action="login/updateText.php" method="post">
    <p>
  File being modified: <textarea name="name" id="name">about.php</textarea>
        <textarea name="editor1" id="editor1">
      <?php echo file_get_contents('about.php');?>
    </textarea>
        <script>
            CKEDITOR.replace( 'editor1' );
        </script>
    </p>
    <p>
        <input type="submit">
    </p>
</form>
</body>
</html>

but after editing this:

<div class="menuslct">
<table border="0" style="text-align:center; width:980px">
<tbody>
    <tr>
        <td><a href="/en/aboutus"><img src="/common/img/icons/aboutus.png" style="height:80px; width:80px" /></a></td>
        <td><a href="/en/aboutus/ourteam"><img src="/common/img/icons/12 our team.jpg" style="height:78px; width:78px" /></a></td>
        <td><a href="/en/aboutus/howtohelp"><img src="/common/img/icons/11 help.jpg" style="height:78px; width:78px" /></a></td>
    </tr>
    <tr>
        <td>About Us</td>
        <td>Our Team</td>
        <td>How to help</td>
    </tr>
</tbody>
</table>
</div>

the saved html code looks like this:

<div class="\&quot;menuslct\&quot;">
<table border="\&quot;0\&quot;" style="\&quot;height:80px">
<tbody>
    <tr>
        <td>About Us</td>
        <td>Our Team</td>
        <td>How to help</td>
    </tr>
</tbody>
</table>
</div>

<p><a href="\"><img src="\" style="\&quot;height:78px" /></a><a href="\">  <img src="\" style="\&quot;height:78px" /></a></p>

and here is updateText.php:

<?php

$filename = $_POST['name'];
$str = $_POST['editor1'];
$fh = fopen($filename, "w");
fwrite($fh, $str);
fclose($fh);

header("Location: modify.php"); 

?>

So I have no idea as to what I'm messing up...

3
  • please show how you're saving the html (updateText.php) Commented Nov 12, 2013 at 14:15
  • edited to add updateText.php (sorry I forgot :P ) Commented Nov 12, 2013 at 14:19
  • turn off magic quotes.. Commented Nov 12, 2013 at 14:31

2 Answers 2

1

It looks like magic quotes messes up your $_POST vars.

Disable it in your php.ini file:

; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off

Disabling Magic Quotes

Sign up to request clarification or add additional context in comments.

3 Comments

I putted the line you gave me at the end of the /etc/php5/apache2/php.ini file but it's still the same...
So this solved it!! if (get_magic_quotes_gpc()) { function stripslashes_gpc(&$value) { $value = stripslashes($value); } array_walk_recursive($_GET, 'stripslashes_gpc'); array_walk_recursive($_POST, 'stripslashes_gpc'); array_walk_recursive($_COOKIE, 'stripslashes_gpc'); array_walk_recursive($_REQUEST, 'stripslashes_gpc'); }
ok fine..but if you had restarted the server after editing the php.ini it should have worked..
0

If you want to add HTML code with CKEditor you must first make sure that you have pressed the "Source" button first otherwise it is going to encode the inputs and you will get the issue above.

1 Comment

wether I press source before hiting the post button or not it has the exact same result...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.