Welcome Guest, Not a member yet? Register   Sign In
Problem with Editor in view (Solved).
#1

[eluser]gazza7364[/eluser]
Hi

I'm trying to solve a problem, I'm not sure if, it is to do with config files in apache web server or how codeigniter works with editors.

The problem I'm having is, which ever editor I use (Ckeditor or Tinymce) i get the same output summited to the database.

This is the code before I submit
Code:
<p>This is to show what code is bein summited</p>
<p>Test 123</p>


This is the code after submitted
Code:
&amp;lt;p&amp;gt;This is to show what code is being summited &amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;Test 123&amp;lt;/p&amp;gt;

So during the submit the code is changed, which is no use when sending back to the view page.

Their is most probally a simple answer, I have tried google and the help guide without succes.

Thanks for looking.
#2

[eluser]Krystian[/eluser]
Hi, the question is if this bothers you somehow?

such a thing

&amp;lt;

should return "<" so when you have this saved in db and further you retrieve such a data it shoudn`t couse any problems.



#3

[eluser]gazza7364[/eluser]
[quote author="Krystian" date="1327239816"]Hi, the question is if this bothers you somehow?

such a thing

&amp;lt;

should return "<" so when you have this saved in db and further you retrieve such a data it shoudn`t couse any problems.



[/quote]

The problem is, that when its saved in the db, &amp;it are inserted into the db and this is what is sent to the view. so when I view the page it is showing following when I visit the page.
Code:
&amp;lt;p&amp;gt;testing l need help help to remove these codes. &amp;amp;nbsp;.&amp;lt;/p&amp;gt;
So codes are not getting converted to what they should be.
#4

[eluser]domainsvault[/eluser]
Its been a while since I've used either editor. But from what I remember of them thats in part the editors themselves. It could also be CI too, if your posting your data through the "form" helper and having validation done on posts before storage. Though then again validation won't convert the data I don't believe.

All in all though whats basically happening is when the data is being submitted your editors being the likely culprits are running the data through htmlentities and or htmlspecialchar which basically takes the data and makes it "safe" to store. I enclose safe in quotes cause all in all you can store whatever you want in the DB in any form even raw html and thats perfectly fine. However the logic is typically if theres a way for a user to submit something to a script for processing be it to display on page instantly or store it in a DB then you want to sanatize the inputs so no one attempts to maliciously cause your page harm by injecting code to do such things.

if your storing your input in a DB its best to just let it be. However if your doing this in a sense to be able to go into your code at later dates remotely for example or you want to allow users to post html and you can trust them to not do something foul, then you can always run your input though html_entity_decode when displaying it back on the page later when calling it back out through the DB. This way it won't look like printed code on the screen it should work as normal html.

Side note: storing PHP and expecting it to work within the html won't work PHP renders upon initial load, and if you echo out a string with php code in it from a DB, it will render it out as a string not working code. Also its fairly unlikely it has anything to do with how your server is configured..
#5

[eluser]Krystian[/eluser]
try to use html_entity_decode("your data retrieve from db");

I`ve just simalated this and its working
#6

[eluser]gazza7364[/eluser]
[quote author="Krystian" date="1327242486"]try to use html_entity_decode("your data retrieve from db");

I`ve just simalated this and its working[/quote]

Hi

Thanks that has worked a treat.

Thanks for all your replies.




Theme © iAndrew 2016 - Forum software by © MyBB