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.

Recommended Answers

All 6 Replies

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.

Member Avatar for diafol

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.

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?

Member Avatar for diafol

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.