在一个文件中 怎样获取当前页中html中提交的数据??
<?php
if($_SERVER['REQUEST_METHOD'] == "post")
{
//require( 'file' );
if(isset($_REQUEST["data"]))
{
echo "成功";
}
else
{
echo "失败";
}
}
?>
<html>
<head>
<title> 请您注册</title>
</head>
<form class="navbar-form pull-right" action="" method="post">
<input class="span2" type="text" placeholder="UserName" name="name">
<input class="span2" type="password" placeholder="Password" name="password">
<button type="submit" class="btn">提交</button>
</form>
</html>
用这个if($_SERVER['REQUEST_METHOD'] == "post") 判断可以吗??? 本帖最后由 longrbl 于 2016-12-18 12:54 编辑
你可以这样判断
$post = $this->input->post();
if(!empty($post)){
echo '确定是一个post请求';
print_r($post);
}else{
echo '不是一个post请求';
}
longrbl 发表于 2016-12-18 12:52
你可以这样判断
但是这样的方式并不能实时监测submit啊 当我点击提交之后获取不到数据啊? 可以获取的这个代码写到你post的页面去 longrbl 发表于 2016-12-18 13:30
可以获取的这个代码写到你post的页面去
明白了 这个写道post的页面完全没问题但是 我现在想在当前页面获取以下数据·就是说获取一下我要POST的数据、 测试下就知道了 不明白你要做什么?提交的页面不是很容易就可以获取到数据么?用 $_POST 呀? print_r($_REQUEST); 你是不是想获取没提交前的数值呢?用jquery获取ID的值
页:
[1]