开发者

$_GET and $_POST

开发者 https://www.devze.com 2022-12-18 12:35 出处:网络
I have a form and the method is set to post on the开发者_StackOverflow中文版 action page when I use $_POST i dont get the value but if I use $_GET or $_REQUEST I do.

I have a form and the method is set to post on the开发者_StackOverflow中文版 action page when I use $_POST i dont get the value but if I use $_GET or $_REQUEST I do.

This does not make sense. Could someone just clarify it for me?

The code of the form is

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

Just realized I am missing the = after method.


It sounds like you've misplaced or mistyped the method attribute and your form is defaulting to HTTP GET. The form should look like this:

<form method="post" action="file.html">


What's the method set to in the HTML for your form, eg:

<form method="POST" ...>


In PHP ini file, the default setting GPC (Get, Post, Cookie) and Request array has that in itself. And make sure that you really the the POST in the action attribute.


It looks like you typoed your HTML:

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

should be

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

You're missing an equal sign.


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

your missing equal sign after the method


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

The easiest to see difference is:
Parameters submitted with GET appear in the adress bar, i.e.
http://example.com/index.php?page=home

passes the key page with the value home to $_GET.
Post parameters do not appear in the adress bar.


Your method attribute is wrong, should be:

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


Hehe :-)

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

Your sloppy way of writing is not good for coding...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号