PHP表单帖子总是空的 [英] PHP Form post always empty

查看:147
本文介绍了PHP表单帖子总是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一定是配置问题,我希望有人能够提供帮助。我在我的本地主机上建立了一个新项目,我的PHP帖子总是空的。以下是这个例子:

我的表单页面:

 < form id =loginFormaction =/ post / loginmethod =post> 
< input type =textname =username/>
< input type =passwordname =password/>
< input type =submitvalue =Submit/>
< / form>

和/post/login/index.php页面:

 <?php 
var_dump($ _POST);
?>

结果:

  array(0){} 

好像没有代码问题,问题是什么?

解决方案

行为属性需要指向实际

尝试这样做:

 < form id =loginFormaction =/ post / login / index.phpmethod =post> 


this must be configuration issue and I'm hoping somebody can help. I'm setting up a new project on my localhost and my PHP Post is always empty. Here's the example:

My Form Page:

<form id="loginForm" action="/post/login" method="post">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <input type="submit" value="Submit" />
</form>

and the "/post/login/index.php" page:

<?php
var_dump( $_POST );
?>

the result:

array(0) { }

It seems like there's no code issue so what's the problem?

解决方案

The action attribute needs to point to the actual script of the page you want to go to.

Try doing this instead:

<form id="loginForm" action="/post/login/index.php" method="post">

这篇关于PHP表单帖子总是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆