Home > Backend Development > PHP Problem > What to do if php post fails

What to do if php post fails

藏色散人
Release: 2023-03-12 12:56:02
Original
2037 people have browsed it

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.

What to do if php post fails

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[&#39;ss&#39;];?>
<form action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>" method="post">
<input name="ss" type="text" />
<input type="submit" name="submit">
</form>
Copy after login

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=&#39;&#39;
Copy after login

Instead of:

action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>"
Copy after login

Also, Add this to line 2 to see what, if anything, is stored in the $_POST array:

var_dump( $_POST );
Copy after login

Hmm... so it's empty on commit? Try adding this to the top of your php file:

if(empty($_SERVER[&#39;CONTENT_TYPE&#39;]))
{ 
  $_SERVER[&#39;CONTENT_TYPE&#39;] = "application/x-www-form-urlencoded"; 
}
Copy after login

Ok now check your php.ini (usually sudo or root is required in /etc):

post_max_size = 8M
variables_order = "EGPCS"
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template