本文目录一览:
1、php怎么获取表单中提交的数据?
2、php提交怎么获取编辑器的值
3、表单提交到另一个php页面,如何保存获取表单值
4、PHP怎么获取表单提交的数据啊?
5、php一个表单提交多个页面,怎样获取按钮提交过来的值
6、jquery中的$.post(),提交到php端如何获取值?
php怎么获取表单中提交的数据?
在获取表单数据中,最常用的自动全局变量是$_GET
和$_POST
,它们分别获取通过GET方法提交的数据和通过POST方法提交的数据。
比如一个名称为"user"的文本框表单控件,如果用GET方法提交,可以用 $_GET["user"]
或者 $_GET['user']
获取它提交的值。
php提交怎么获取编辑器的值
你这用的是kindeditor编辑器,你的textarea的name是task_step
。
html代码
<textarea id="task_step" name="task_step" style="width:100%;height:300px;"></textarea>
js代码
<script>
var editor;
KindEditor.ready(function(K) {
editor = K.create('#task_step');
});
</script>
提交的时候直接$_POST["task_step"]
就可以了。
表单提交到另一个php页面,如何保存获取表单值
一个表单无法同时提交多个页面,只有提交给一个页面后,再提交给下一个页面,就像安装软件时候的“下一步”一样,是一步一步的传递的。
PHP文件获取“上一步”表单传递来的数据,方法是使用数组$_GET
和$_POST
,例如表单里面有<input type="text" name="user" value="abc">
,那么在PHP里面就有$_GET["user"]
或者$_POST["user"]
(根据表单的提交方法),其值为"abc"
。
PHP怎么获取表单提交的数据啊?
一、用file_get_contents
以get方式获取内容,需要输入内容为:
<?php
$url = '';
$html = file_get_contents($url);
echo $html;
?>
二、用file_get_contents
函数,以post方式获取url,需要输入内容为:
<?php
$url = '';
$data = array('foo' => 'bar');
$data = http_build_query($data);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$ctx = stream_context_create($opts);
$html = @file_get_contents($url, '', $ctx);
?>
三、用fopen
打开url,以get方式获取内容,需要输入内容为:
<?php
$fp = fopen($url, 'r');
$header = stream_get_meta_data($fp); //获取信息
while (!feof($fp)) {
$result .= fgets($fp, 1024);
}
echo "url header: {$header} <br>";
echo "url body: $result";
fclose($fp);
?>
四、用fopen
打开url,以post方式获取内容,需要输入内容为:
<?php
$data = array('foo2' => 'bar2', 'foo3' => 'bar3');
$data = http_build_query($data);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\nCookie:cook1=c3;cook2=c4\r\n" .
"Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$context = stream_context_create($opts);
$html = fopen(';id2=i4', 'rb', false, $context);
$w = fread($html, 1024);
echo $w;
?>
五、用fsockopen
函数打开url,以get方式获取完整的数据,包括header和body,需要输入内容为:
<?php
function get_url($url, $cookie = false)
{
$url = parse_url($url);
$query = $url['path'] . "?" . $url['query'];
echo "Query:" . $query;
$fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80, $errno, $errstr, 30);
if (!$fp) {
return false;
} else {
$request = "GET $query HTTP/1.1\r\n";
$request .= "Host: $url[host]\r\n";
$request .= "Connection: Close\r\n";
if ($cookie) $request .= "Cookie: $cookie\n";
$request .= "\r\n";
fwrite($fp, $request);
while (!@feof($fp)) {
$result .= @fgets($fp, 1024);
}
fclose($fp);
return $result;
}
}
// 获取url的html部分,去掉header
function GetUrlHTML($url, $cookie = false)
{
$rowdata = get_url($url, $cookie);
if ($rowdata) {
$body = stristr($rowdata, "\r\n\r\n");
$body = substr($body, 4, strlen($body));
return $body;
}
return false;
}
?>
参考资料:
php-file_get_contents
php一个表单提交多个页面,怎样获取按钮提交过来的值
一个表单无法同时提交多个页面,只有提交给一个页面后,再提交给下一个页面,就像安装软件时候的“下一步”一样,是一步一步的传递的。
PHP文件获取“上一步”表单传递来的数据,方法是使用数组$_GET
和$_POST
,例如表单里面有:
<input type="text" name="user" value="abc">
那么在PHP里面就有$_GET["user"]
或者$_POST["user"]
(根据表单的提交方法),其值为"abc"
。
jquery中的$.post(),提交到php端如何获取值?
AJAX 提交后在控制器里 dump($_POST)
你提交的数据,可在控制台里看返回的数据查看是否有结果。
在控制器里 echo "ok"
是返回结果,页面中的 JavaScript 中的 if(data == 'ok'){....}
才可执行。