barns
barns

Reputation: 352

PHP POST request not working when http:// in variable

I have this really wierd question.

When I submit my form, if one of the variables is, say http://www.youtube.com, the page gives a NO DATA RECEIVED error and fails.

Not sure if it is a server setting, or something I can fix in the PHP script.

The post processing script is very simple for testing:

<?php
foreach($_POST as $a=>$b) echo "{$a}={$b}<br />";
?>

This is fine on some servers, not on others, which makes me think it's a server setting.

Any insight will be gratefully received

Upvotes: 3

Views: 2689

Answers (1)

Vlad Preda
Vlad Preda

Reputation: 9920

Things to check for in php.ini:

  • post_max_size # should be different from 0
  • variables_order # should be = "EGPCS"
  • max_input_vars # should be higher than the number of variables you pass

Things to check for in the HTML form:

  • the fields and submit button are inside the form
  • the form has method="POST"
  • if the form has files, check the enctype, it should be multipart/form-data, if not it should be application/x-www-form-urlencoded
  • Look for <input type="hidden" name="MAX_FILE_SIZE" value="..." /> - is it big enough ?

If all are fine, check if mod_security is enabled, and also check .htaccess for things like RewriteCond %{REQUEST_METHOD} POST, and the rule after it.

Check if your browser sends the data. In Chrome network tab I see something like this:

enter image description here


You can also try the following:

var_dump(get_defined_vars());

or

$vars = get_defined_vars();
foreach ($vars as $var) {
     echo "<br><b>{$var}</b>";
     var_dump($$var);
}

and check the list of declared variables.

PS:

I presumed that you use Apache, since you didn't include this info. Also, try a different browser, and see if it changes anything.

PS2: I like to check config settings in the command line with:

~$ php -i | grep -i variables_order
variables_order => GPCS => GPCS

Upvotes: 3

Related Questions