最大POST变量PHP?

时间:2017-07-09 11:33:44

标签: php html

我从HTML中向PHP提交了5个蜇 当我尝试传递5个字符串时,我在goDaddy(内部服务器错误)上出现错误但它适用于4个字符串。 我无法弄清楚这个问题。是否有最大量的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 

2 个答案:

答案 0 :(得分: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'] : "" ;

答案 1 :(得分:0)

没有最大量的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 />"; 
}

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