【问题标题】:Maximum POST Variables PHP?最大POST变量PHP?
【发布时间】:2017-07-09 19:57:03
【问题描述】:

我正在从 HTML 向 PHP 提交 5 个字符串
当我尝试传递 5 个字符串 但它适用于 4 个字符串时,我在 goDaddy 上收到错误(内部服务器错误)。 我无法弄清楚问题所在。是否有可以传递的最大 POST 变量数量? 我为 4 个字符串工作,当我添加另一个字符串时出现错误。 Godaddy 支持团队与他们通电话几个小时都没有用。 编码在 WAMP 上运行良好!

HTML

<form action="login.php" method="post">


  <input type="text" name="username" placeholder="Username"/>
  <input type="password" name="password" placeholder="Password"/>
  <input type="text" name="clientID" id="client_id" value="" />
   <input type="text" name="redirect" id="redirect_uri" value="" />
    <input type="text" name="webstate" id="stateValue" value="" />







  <button>Login</button>
</form>

PHP

$myusername=$_POST['username']; 
$mypassword=$_POST['password']; 
$client_id=$_POST['clientID']; 
$redirect_uri=$_POST['redirect'];
/*$state=$_POST['webstate']; */  <---- When i add this line it Shows 
                                       Internal Server Error 






echo "Username: ".$myusername. "<br />";
echo "Client ID: ".$client_id. "<br />";
echo "Redirect URL: ".$redirect_uri. "<br />";
/*echo "State: ".$state. "<br />"; */ <--- I commented this becouse it  
                                           useless 

【问题讨论】:

  • 有一个限制,但默认情况下它是 1,000 个 post vars...如果您遇到内部服务器错误,请检查日志以查看该错误是什么
  • 日志没用,它们似乎没有显示很多错误。只是一堆IP地址和废话的日志
  • 你在看什么日志,听起来只是网络服务器日志
  • 检查error_log服务器上保存PHP的文件,找出是哪一行造成了错误

标签: php html


【解决方案1】:

在将发布的值分配给变量或对其进行操作之前检查是否设置了这些值非常重要。

$myusername = isset($_POST['username']) ? $_POST['username'] : "" ;

$mypassword= isset($_POST['password']) ? $_POST['password'] : "" ;

$client_id= isset($_POST['clientID']) ? $_POST['clientID'] : "" ;

$redirect_uri= isset($_POST['redirect']) ? $_POST['redirect'] : "" ;

$state= isset($_POST['webstate']) ? $_POST['webstate'] : "" ;

【讨论】:

  • 好的,现在错误消失了,当我回显 $state 变量时,它没有显示任何内容。但在 HTML 文本字段中,我可以清楚地看到文本
  • 在这种情况下,您输入的名称可能不是 webstate。你可以试试:var_dump($_POST);?它返回什么?
【解决方案2】:

POST请求没有最大数量 你的代码没问题,我试过了,效果很好 我只是添加了一行来检查 POST 值

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

$myusername = $_POST['username']; 
$mypassword = $_POST['password']; 
$client_id = $_POST['clientID']; 
$redirect_uri = $_POST['redirect'];
$state = $_POST['webstate']; 

echo "Username: ".$myusername. "<br />";
echo "Client ID: ".$client_id. "<br />";
echo "Redirect URL: ".$redirect_uri. "<br />";
echo "State: ".$state. "<br />"; 
}

如果问题仍然出现,请尝试其他主机

【讨论】:

  • yahyazini 的遮阳篷已唤醒,但现在 $state 为空。但在“状态”的 html 文本字段中,它有一个文本
  • 意思是在 HTML 表单中的“状态”字段中有一个文本,但是当我把它放到 php 中时它是空的
  • 我将代码上传到免费主机,没有问题检查:admitted-curls.000webhostapp.com/stack.php
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多