Home >Backend Development >PHP Tutorial >ThinkPHP小白 POST无效

ThinkPHP小白 POST无效

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:13:321030browse

本帖最后由 bluicezhen 于 2013-03-18 22:38:39 编辑

thinkphp post php

根据POST的值来显示页面,但似乎获取不到POST的值:
$username = $this->$_POST['username'];//$name = $this->_post('name'); 换成这行业无效。$user   =   M('user');$data =   $user->where('username="'.$username.'"')->field('id,username')->find(); if($data) {	$this->success('成功');}else{	$this->error('失败');}


但是用_param方法就成功了。请高手解释一下。

回复讨论(解决方案)

你的post参数不是username吗?

$this->_post('name');当然无效,$this->_post('username');试下

楼主dump($_POST);试一下爱

楼主,一种就是

$username = $_POST['username']

或者就是
$username = $this->_post('username'); 换成这行业无效。

我也遇到这个情况了,目前还没解决,不过我发现都没执行到,Action.class.php 的__call函数

你是如何post数据的
是不是开启了路由模式

根据POST的值来显示页面,但似乎获取不到POST的值:

$username = $this->$_POST['username'];//$name = $this->_post('name'); 换成这行业无效。$user   =   M('user');$data =   $user->where('username="'.$username.'"')->field('id,username')->find(); if($data) {	$this->success('成功');}else{	$this->error('失败');}


但是用_param方法就成功了。请高手解释一下。
你是如何post数据的 是否开启了路由模式

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn