我需要使用 PHP 提交一个表单以将其发送到 CouchBase 并将其与包含的 HTML 标签一起存储在那里(<p>
标签等等,只是基本的 HTML)。我正在使用 CLEditor 创建 HTML 标签,供人们输入到文本字段中,这样当有人在表单中输入粗体文本时,它看起来像这样:
<span style="font-size: large;">Highlights of what your hotel has to offer.</span>
因此,我开始使用 action 属性通过表单发送信息,但是如何通过包含 HTML 标记的方式发送该信息?
谢谢你的帮助!
更新:
想我只是做一个 cURL 请求并调用该字段。但是我用什么来调用该字段中的信息来提取原始 html?
PHP:
<?php
session_start();
$curl = curl_init();
$url = $_SESSION['extranetRequest'] . '?action=sendDesc&guid=' . $_SESSION['guid'] . '&username=' . $_SESSION['u_name'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_POST[''] );
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$content = curl_exec($curl);
if (curl_errno($curl)) {
print curl_error($curl);
} else {
curl_close($curl);
}
?>
更新 2:
好的,所以我对自己在做什么有了更好的了解。我正在使用 CLEditor 来真正允许人们编辑自己的文本以及不提交以在其他地方查看的内容。但是现在我无法从中获取要发布的数据,如下所示:
HTML:
<form action="assets/php/sendHTML.php" name="hotelDescForm" id="hotelDesc" method="POST" class="hotelDesc">
<div class="row push-down">
<div class="span4">
<h1 style="font-size: 24px;"><span class="orange-title">hotel description</span></h1>
<textarea class="textarea" rows="8" style="width: 900px;" name="hotelDesc" class="hotelDesc" id="hotelDesc" value="">Text Is Here. Start working.</textarea>
</div>
</div>
<div class="row">
<br>
<button type="submit" name="submit" id="update" class="btn btn-success btn-large"><i id="update-button" class="icon-refresh"></i> Update Information</button>
</form>
jQuery 只是调用 textarea 来使用 CLEditor 配置文本框。
PHP:
<?php
session_start();
$data['data'] = $_POST['demo'];
$desc = json_encode($data);
$curl = curl_init();
$url = $_SESSION['extranetRequest'] . '?action=sendDesc&desc='. var_dump($_POST) .'&guid=' . $_SESSION['guid'] . '&username=' . $_SESSION['u_name'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, var_dump($_POST) );
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$content = curl_exec($curl);
if (curl_errno($curl)) {
print curl_error($curl);
echo "<script language='javascript'>\n";
echo "alert('Failed'); window.location.href='https://hotelmobidev.jvgames.com/profile';";
echo "</script>\n";
} else {
curl_close($curl);
echo "<script language='javascript'>\n";
echo "alert('Worked'); window.location.href='https://hotelmobidev.jvgames.com/profile';";
echo "</script>\n";
}
?>
CLEditor 所做的是创建一个 iFrame,所以我需要一种方法来解决这个问题并将数据发布到文本框中。多谢你们!