0

i'm trying to analyse this php, i noticed that whenever i enter values into textfield,
like input type="text", and i retrieve the data, it is not showing in the address bar like,
www.host.com/login.php?usermae="user"&password="pass".
Please why is this happening, is it a new feature in php? or something else.

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by |-|x
0

afaik PHP has never done this for input values by default. Form input values are available via the $_POST variable on the server. If you want to pass them via the url, I think you have to construct the url yourself as a string and link or redirect to it. Ten the values will be available via the $_GET and REQUEST objects.

But do you really need / want to pass this data as a URL parameter? especially for username and password data this would not be recommended.

0

forms pass data as get if no 'method' attribute is set (get = default)
if you set the method attribute to post, you pick up the data with the $_POST superglobal as opposed to the $_GET superglobal (as mentioned by Hearth).

I agree entirely with Hearth that you should NOT be passing login details via the url/get route.

0

Correct me if I am wrong though, Al, but even if the default form method is used and the data sent as a GET request, it still would not appear in the query string. Right?

Edited by |-|x

0

Yes it will if the form fields have a name attribute. Try this and see:

<form>
    <input name="myfield" />
    <input type="submit" value="go" />
</form>

That reminds me, perhaps the OP didn't give a name attribute, just an id

Edited by diafol

0

thnx 4 d advice guys, i guess i won't use $_GET for username and password then, but like Heart asked will those nmes appear in the URL like this? http://example.com?name="myfield" bcos i noticed it doesn't appear on some site.

0

I tested as Al said, if the form is using the default GET method then it does generate url parameters, but if using form method="POST" then nothing is added to the URL and values are available via $_POST

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.