HTML codes showing in viewpage HTML data

#1
[eluser]mi6crazyheart[/eluser]
Hello Guys,
I'm a new to CI. Just using it in my project from last 2 months. I've a comment section in my project. Where any one can give comments. Every things are going perfect but when ever any one putting HTML content(image/videos) & then when those are showing back in the comment section... direct HTML codes are showing in the comment page rather than HTML content(image/videos).

ex: when i'm saving any "embed youtube video code" in the comment box & save that the out put comes as "raw Embed Video codes" rather than Youtube Video.....

I feel like it must be a minor thing but really can't understand where the fault has occurring. Plz, if any body have the solution reply me back as soon as possible.

#2
[eluser]pickupman[/eluser]
Check the php.net site for the function html_entity_decode that might help point you in the right direction.

#3
[eluser]Imran Tariq[/eluser]
Pikcupman is right. You should store it without decoding the original comments.

#4
[eluser]mi6crazyheart[/eluser]
I used that "html_entity_decode" but now all the EMBED video codes are getting print rather than the original video. I also tried to use "htmlspecialchars_decode" but it also not doing the same thing(showing the codes but not the original video)

My Controller :
Code:
$this->form_validation->set_rules('CommentMessage', 'Comment', 'htmlspecialchars_decode|trim|required|min_length[2]|max_length[5000]|xss_clean');

My Model :
Code:
$CommentMsg = auto_link(auto_typography($this->input->post('CommentMessage')),'both', TRUE);
$this->db->set('CommentContent', $CommentMsg);

#5
[eluser]pickupman[/eluser]
You will need to use a combo of htmlentities in your callback to save the data in the db as non html characters. Then when you want to display it back on a page you will then use html_entitiy_decode the string to convert it back to html.

#6
[eluser]mi6crazyheart[/eluser]
@pickupman
Thanks a lot. Your suggestion worked....... :coolsmile:


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.