Ckeditor并使用$ _POST插入到Mysql中 [英] Ckeditor and using $_POST to insert into Mysql

查看:182
本文介绍了Ckeditor并使用$ _POST插入到Mysql中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我一直在敲我的头几个小时。



我使用jquery来发布序列化表单。

我有ckeditor在网页上,根据他们的说明,我所要做的就是设置帖子到一个变量,它会工作。它不是。 $ _POST ['TEXTAREA_NAME']为空。



没问题。我可以只使用jquery将数据附加到textarea之前的帖子发生。现在我得到的是\r\\\



帮助请,什么是最好的方式从ckeditor到mysql的数据?



文字是:

 < textarea id =contentname =content> ;<?php if($ _ GET ['act'] ==edit){echo getDigestInfo($ articleID,content); }?>< / textarea> 

Jquery:

 code> function saveNew(){
$ .post(crud / man-digest.php?act = add,$(#edit-content-form)。serialize $ b function(data){
$(form .message)。append(data);
}
,json
);
}

PHP:

  $ articleID = intval($ _ POST ['id']); 
//执行更新
$ article_title = mysql_prep($ _ POST ['title']);
$ article_content = mysql_prep($ _ POST ['content']);
$ article_system = mysql_prep($ _ POST ['system']);
$ article_updated = mysql_prep($ _ POST ['updated']);
$ article_datecreated = $ _POST ['datecreated'];
$ query =UPDATE techdigest SET
title ='{$ article_title}',
content ='{$ article_content}',
lastupdate = CURDATE(),
system ='{$ article_system}',
datecreated = DATE('{$ article_datecreated}')
WHERE id = {$ articleID};
$ result = mysql_query($ query);


解决方案



想出来了。



在更新textarea时,最好使用.html()而不是.append()



至今!



~~~~哇,


Alright, so I have been banging my head for hours on this. Time to turn to the pros.

I am using jquery to post the serialized form.

I have ckeditor on a page, according to their instruction all I have to do is set the post to a variable and it will work. Well it doesn't. $_POST['TEXTAREA_NAME'] is empty.

alright, no problem. I can just use jquery to append the data to the textarea before the post takes place. now all i get is \r\n.

help please, what is the best way to get the data from ckeditor to mysql?

Text are:

<textarea id="content" name="content"><?php if($_GET['act'] == "edit"){ echo getDigestInfo($articleID, "content"); } ?></textarea>

Jquery:

function saveNew(){
            $.post("crud/man-digest.php?act=add", $("#edit-content-form").serialize(),
                function(data){
                    $("form .message").append(data);
                }
                ,"json"
            );
        }

PHP:

$articleID = intval($_POST['id']);
                    // Perform Update
                    $article_title = mysql_prep($_POST['title']);
                    $article_content = mysql_prep($_POST['content']);
                    $article_system = mysql_prep($_POST['system']);
                    $article_updated = mysql_prep($_POST['updated']);
                    $article_datecreated = $_POST['datecreated'];
                    $query = "UPDATE techdigest SET 
                                title = '{$article_title}', 
                                content = '{$article_content}',
                                lastupdate = CURDATE(),
                                system = '{$article_system}',
                                datecreated = DATE('{$article_datecreated}')
                                WHERE id = {$articleID}";
                    $result = mysql_query($query);

解决方案

Well, Feel pretty dumb here.

figured it out.

when updating the textarea it is best to use .html() instead of .append()

works so far!

~~~~wow,

这篇关于Ckeditor并使用$ _POST插入到Mysql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆