test automate
test automate

Reputation: 21

Maximum POST Variables PHP?

I am submitting 5 stings to PHP from HTML
I get an error on goDaddy (Internal Server error) when i try and pass 5 strings BUT it works for 4 strings. I cannot figure out the problem. Is there a maximum amount of POST variables that can be passed? I works for 4 strings, and when i add another string i get an error. Godaddy support team was useless was on the phone with them for Hours. The coding works fine on 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 

Upvotes: 1

Views: 168

Answers (2)

Aymen bz
Aymen bz

Reputation: 388

there is no maximum amount of POST request Your code Is Ok, I tried it and it works perfectly i just added one line to check the POST values

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 />"; 
}

If the problem still appears try a different host

Upvotes: 0

yahyazini
yahyazini

Reputation: 717

It's very important to check if the posted values are set before assigning them to a variable or doing something with them.

$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'] : "" ;

Upvotes: 1

Related Questions