$ _GET and $ _POST

I have a form and the method is set to publish on the action page, when I use $_POST , I do not get the value, but if I use $_GET or $_REQUEST , I do.

This makes no sense. Can someone just clarify this for me?

Form code

 <form action="create.php" method"POST"> 

I just realized that I lack the method = after.

+4
source share
9 answers

It looks like you made a mistake or mistakenly specified a method attribute, and your default form is HTTP GET. The form should look like this:

 <form method="post" action="file.html"> 
+9
source

What method set in HTML for your form, for example:

 <form method="POST" ...> 
+1
source

The default PHP ini file uses the default GPC (Get, Post, Cookie) and an array of requests. And make sure that you are truly POST in the action attribute.

+1
source

It looks like you sealed your HTML:

 <form action="create.php" method"POST"> 

it should be

 <form action="create.php" method="POST"> 

You are missing an equal sign.

+1
source
 <form action="create.php" method="POST"> 

your missing equal sign after the method

+1
source

POST and GET are different ways of transmitting form data, they use different methods of sending the entered values ​​to your application and should be handled differently. PHP uses $ _POST for values ​​represented by a form with a method = "post" and $ _GET for values ​​represented by a form without a method or method = "get". $ _REQUEST is a combination of $ _POST and $ _GET.

The easiest way to see the difference is:
Parameters represented by GET are displayed in the address bar, i.e.
http://example.com/index.php?page=home

passes the key page with the value home to $ _GET.
Message parameters are not displayed in the address bar.

+1
source

Your method attribute is incorrect, should be:

 <form action="create.php" method="POST"> 
0
source

Hehe :-)

 <form action="create.php" method="POST"> 

Your careless way of writing is not suitable for coding ...

0
source

The error seems to be missing "=" :) BTW, the variable $ _REQUEST is not just a combination of $ _POST and $ _GET, it is an associative array that by default contains the contents of $ _GET, $ _POST and $ _COOKIE .;)

0
source

Source: https://habr.com/ru/post/1299947/


All Articles