另一个就地编辑器 - 一个jQuery就地编辑插件

Another In Place Editor - a jQuery edit in place plugin

本文关键字:编辑 插件 jQuery 编辑器 另一个 一个      更新时间:2023-09-26

我正在尝试弄清楚如何将更改的值提交到数据库,但到目前为止,我根本没有太多运气。 知道我做错了什么吗?

JS文件:

$("#editme5").editInPlace({
    /*saving_animation_color: "#ECF2F8",
    callback: function(idOfEditor, enteredText, orinalHTMLContent, settingsParams, animationCallbacks) {
        animationCallbacks.didStartSaving();
        setTimeout(animationCallbacks.didEndSaving, 2000);
        return enteredText;
    },*/
    url: "server.php",
    params: "name=BUSINESS_NAME"
});

PHP文件:

include('database.php');
$_GET['name'];
$_NAME=$_GET['name'];
$update = $_POST['update_value'];
$insert = "UPDATE CLIENTS SET ".$_NAME."='".$update."'";
mysql_query($insert) or die (mysql_error());

尝试更改:

include('database.php');
$_GET['name'];
$_NAME=$_GET['name'];

自:

include('database.php');
$_NAME=$_POST['name'];

文档说:

提交就地编辑器表单后,它会将 POST 请求发送到 编辑器参数中指定的 URL 以及三个 表单域

通过编写$_NAME=$_GET['name'];您期望值来自GET请求,但插件使用POST请求发送值。我想这就是这里的罪魁祸首。

另外,请记住Marc B在他的评论中所说的话。该代码非常容易受到SQL注入攻击。要使其不那么容易,请至少使用mysql_real_escape_string()(更多:http://php.net/manual/pl/function.mysql-real-escape-string.php)或使用预准备语句(一个好的教程:http://www.ultramegatech.com/2009/07/using-mysql-prepared-statements-in-php/)。

尝试使用可以帮助您在采样时捕获$_GET$_POST请求的$_REQUEST...

尝试使用 mysql_real_escape_string 修复 SQL 注入漏洞,有关详细信息,请参阅 http://php.net/manual/en/function.mysql-real-escape-string.php

谢谢