Home > Article > Backend Development > What to do if php post fails
Solution to failed php post: 1. Modify the code to "action=''"; 2. Execute the "var_dump($_POST);" statement; 3. Modify the php.ini file; 4. Restart Just apache.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if the php post fails?
Specific problem description:
PHP POST failed? Not working?
<?php echo $_POST['ss'];?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <input name="ss" type="text" /> <input type="submit" name="submit"> </form>
This code should print what is entered in the textbox name="ss" when submit is clicked.
But it cannot print. What is the problem using method="get" but not post.
Workaround:
If you just refresh the page, do the following:
action=''
Instead of:
action="<?php echo $_SERVER['PHP_SELF'];?>"
Also, Add this to line 2 to see what, if anything, is stored in the $_POST array:
var_dump( $_POST );
Hmm... so it's empty on commit? Try adding this to the top of your php file:
if(empty($_SERVER['CONTENT_TYPE'])) { $_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded"; }
Ok now check your php.ini (usually sudo or root is required in /etc):
post_max_size = 8M variables_order = "EGPCS"
you set Do you understand these two rules? If so, be aware of how much memory to allocate. Depending on your system specs, anything over 2048MB could cause you trouble.
Note: If you make changes to the php.ini file and PHP is running as an apache module, you will need to restart apache. Similar to the following content:
sudo /etc/init.d/httpd restart
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if php post fails. For more information, please follow other related articles on the PHP Chinese website!