简体   繁体   English

没有获取$ _POST数据(PHP 7.1 / Debian 8)LAMP问题

[英]Getting no $_POST data (PHP 7.1/Debian 8) LAMP problems

I have a script coded, I coded it at xampp and it was working. 我有一个脚本编码,我在xampp编码了,并且可以正常工作。 So its at localhost working but I tried to setup this server at Ubuntu, Debian, nothing worked. 因此它在本地主机上工作,但是我尝试在Ubuntu,Debian上安装此服务器,但没有任何效果。

Its like that: 就像那样:

index.php: index.php文件:

switch ($_GET["page"]) {
case ("firstpage"):
  include ("firstpage.php");

  break;

case ("secondpage"):
print_r($_POST);
  break;

index.php?page=firstpage / better said firstpage.php index.php?page = firstpage /最好说firstpage.php

<form action="index.php?page=secondpage" method="POST">
<input type="text" name="test1">
<input type="submit">
</form>

and if I do this with my virtual server (Debian 8, LAMP installed, PHP 7.1, apache2 Header modules activated) then there is a empty array. 如果我使用虚拟服务器(安装了Debian 8,LAMP,PHP 7.1,apache2 Header模块)进行了此操作,则将有一个空数组。

If I do it via xampp (Mac OS X) their is then the output coming.. 如果我通过xampp(Mac OS X)做到这一点,那么输出就来了。

What is the problem? 问题是什么? Somebody can help me via TeamViewer or something like that? 有人可以通过TeamViewer或类似的方式帮助我吗?

Thanks 谢谢

You can try a workaround. 您可以尝试解决方法。 Instead passing your number page in the url, you can send it throught a hidden button. 您可以通过隐藏按钮将其发送给网址,而不是在网址中传递号码页。

index.php 的index.php

if(isset($_POST['page'])){
    if($_POST['page'] == 'firstpage'){
        include ("firstpage.php");
    }elseif($_POST['page'] == 'secondpage'){
        //second page
    }
}else{
//$_POST['page'] is missing
}

and the form 和形式

<form action="index.php" method="POST">
    <input type="text" name="test1">
    <input type="hidden" name="page" value="secondpage">
    <input type="submit">
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM