NicEdit wont save HTML - php

I am trying out NicEdit witch is super light weight and easy to install. The problem is when I use NicEdit its working fine changing content in the textarea - but when I save my content there is no HTML tags in the post? Its all in clear text... Any ideas?

How are you saving with NicEdit?
You can not get the value using "var variable = $("#id").val();" because that will just get the text in the textarea.
NicEdit has a built in ajax save function that you can use. Check out http://wiki.nicedit.com/w/page/519/FrontPage and click on Saving via Ajax.

Related

Cakephp 3.6.14: Display html formatted text in text field

I have a form with some text fields, I want to know if it is possible to display HTML formatted text in an editable text field.
This is the field:
echo $this->Form->control('instructions');
How I can display it HTML formatted? Do I need a WYSIWYG Plugin or there is another way?
Yes, you will need to add something like CKEditor or TinyMCE to your project. Some potentially useful resources for you:
https://github.com/CakeCoded/CkEditor
http://thecoderain.blogspot.com/2017/07/cakephp-3x-add-text-editor-tinyMCE.html
https://www.froala.com/wysiwyg-editor/docs/framework-plugins/cakephp
https://plugins.cakephp.org/packages?category=wysiwyg-editors
Look at the html code generated with the browser inspector, and look at the id of the textarea you want to convert, then just write the necessary JS

HTML form with style attributes need to be inserted in MySQL DB

For a while, I have been trying to figure how to make html form with style atributes where users can style their posts for example (Bold,Center,Font-Size,Link,Image and more).
I'm not very good at english and maybe I am writing my question wrong, but checked out and didn't found any example how to do this, and how this styled information is stored in db.
Image for example, what I want to do: Image
You should use textarea as a field and convert that textarea into editor using jquery.
You can refer Responsive WYSIWYG Text Editor for making textarea to editor.

Strip html tags in php for user view before emailing

I am working on a php project which involves jquery and ajax. The data gets processed through ajax call and the message gets displayed in an email dialog box.
I want the email to be html enabled but the thing is that html tags should be invisible for display before hitting send button. Looking for some help. Thanks in advance.
You can display the content using javascripts innerHTML. It will show the content as marked up by the html, not the html tags and plain text.
Have you tried any code yet? It is not clear what you are trying to do, perhaps you wish for the user to be able to edit the email, if so you would need to use a script that supported your needs.
You say the you are displaying the response which you get from the php server. This approach is not so tidy but if you want this might be a simple solution. Use php strip_tags() and create a different response and add it to your response string with an identifiable key. The you have two response values which one can be used to show to the user and the other can be emailed which contains the original html included response.
you can display the response without the html tags to the user.
Your question is unclear. Are you displaying the response of the ajax call in a textarea? If so, then you can't get rid of the html tags because you will lose all the formatting.
If the content needs to be editable then perhaps try an embedded WYSIWYG editor such as TinyMCE.
If the content doesn't need to be editable then simply insert the html into a div instead of a textarea. See https://api.jquery.com/html/
If you simply want to strip tags then the strip_tags() PHP function will do that for you.

Can i post my edited information in CKEditor?

CKEditor is a word like html editor.
There is a option like saving file
however, this is a javascript:void('save') function, can i modify this save button so that it can post the data into another php page?
Thank you.
Check this one http://dev.ckeditor.com/ticket/4507.

Tiny mce get content with php

Hello I want to use Tiny mce editor and i want to take the text typed by the user and insert it in a database ca n anyone tell me how i would achieve this?
TinyMCE typically replaces a standard form textarea - so on form submission, the textarea contents would be available to you via the standard $_POST array (e.g. $_POST['my_texarea']). You can then validate the contents and do your database insert.
In order to do this you should call editor.triggerSave(); on one of the editor instances on your page.
This will update each elements for which a tinymce editor instance have been created.
Now, you can use an ajax call to send the html elements innerHTML to a remote php script where you can save the content to a db:
var content_to_be_send_using_ajax = $('#my_tinymce_htlm_element_id').innerHTML; // might be a textarea, a div or anything else
// now send it here to your php script
Another option is to use the saveplugin. When the save action is performed the form that the editor is within gets submitted.

Categories