PHP怎么获取input输入框中的数据

PHP与SEO 思享 952浏览

前几天看到一个网页在线主动推送的工具,想着也移植到自己网站上来,多少也能增加点流量。于是很小白的把前段都copy过来了,结果一点提交,啥反应都没有,这才意识到需要后端PHP获取输入框中数据,然后post提交。后端提交好解决,百度一下有现成的,但是如何获取输入框中的数据呢,一起来看看吧

前端

<!--商品查询-->
<input type="text" name="bianhao" value="" maxlength="10" size="10" style="width:100px; margin:0px 0px 0px 25px;height:20px;"/>
<input type="submit" value="商品编号查询" style="margin:0px 0px 0px 10px;cursor:pointer;background-color:#C30D23;border:0px;color:#FFFFFF;width:85px;border-radius:5px;padding:3px 0;font-size:13px;"/>

方法一:php后台接收并查询

public function MallList() {
	//写方法
	$goods=M('shop_goods_info');
	//实例化数据库对应的表
	$codes=I('param.bianhao');
	//获取前台文本框数据
	if(isset($codes) && $codes != '') {
		$where['code']=$codes;
		$this->assign('codes',$codes);
		//显示
	}
}
$info=$classify->where(array('code'=>$code))->find();
//查询语法

方法二:$_GET 或者 $_POST获取

示例代码

<form action='' method='post'>
文本框:<input type='text' name='text'>
<input type='submit' value='提交',name='sub'>
</form>
<?php
if(!empty($_POST['sub'])) {
	echo $_POST['text'];
}
?>

如果是GET 就换成GET

推荐阅读

Function get_magic_quotes_gpc() is deprecated报错解决办法

在 PHP 7.4 及更高版本中, get_magic_quotes_gpc() 函数已被弃用。 This means that code using this function will raise a warning or error.以下是解决......

PHP提示:Warning: count():Parameter must be an array or an object that implements Countable

错误原因:PHP7.2以后,count()函数的参数无效时会抛出warning警告。...

PHP7.4 报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated.

PHP7.4运行项目报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated。只需交换 implode() 函数的两个参数!...