php - 如何在 PHP 中使用 POST 从 CKEDITOR 获取值?

标签 php codeigniter ckeditor

我在获取 HTML 中 CKEDITOR 的值时遇到了问题。 在CKEDITOR中输入一些HTML标签并提交后。 POST 响应没有输出。这是我的代码。我不知道它是否有些复杂,因为我还使用了 jquery-validation 插件。

HTML

<?php echo form_open('users/user/sendEmail', array('id' => 'send-mail-form', 'role' => 'form')); ?>
<div class="row row_field">
    <div class="col-md-12">
        <label for="editor">Email Body:</label>
        <textarea name="email_body" id="editor"></textarea>
    </div>
</div>

JS

$('#editor').ckeditor();

jquery 验证

$('#send-mail-form').validate({
    rules: {
        email_subject: {
            required: true,
            minlength: 15
        },
        email_body: {
            required: true,
            minlength: 50
        }
    },
    messages: {
        email_subject: {
            required: "The Email Subject is required",
            minlength: "The email subject shoud be 15 characters and above."
        },
        email_body: {
            required: "Email body is required",
            minlength: "The email body should be 5o characters and above."
        }
    },
    submitHandler: function(form) {
        form.submit(); //send data
    }
});

PHP 服务器端

public function sendEmail() {

        fp($this->input->post()); //no output 

        fp(htmlentities($this->input->post('email_body'))); //no output also

你能帮我解决这个问题吗?

最佳答案

试试这个:

<script>
    var data = CKEDITOR.instances.editor1.getData();

    // Your code to save "data", usually through Ajax.
</script>

或者

<?php
    $editor_data = $_POST[ 'editor1' ];   // where editor1 is the name of html element
?>

Reference Guide

关于php - 如何在 PHP 中使用 POST 从 CKEDITOR 获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39072352/

相关文章:

php - MySQL - 查询未在 PHP 中运行

php - 比较并显示不匹配的数据

php - mysql 查询不适用于 codeigniter

ckeditor - Typo3/CKEditor : Allow definition list (dl, dt, dd)

php - 如何处理 CURL 中服务器重置的连接

php, json_encode, 带有一个 "left join"查询的嵌套数组

php - 空输出触发错误

javascript - 如何编辑数据表按钮的位置?

javascript - Joomla 不保存字段类型编辑器值

css - Chrome/Safari 中的 Ckeditor 大纲