469,289 Members | 2,330 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Post array values (beginner's question)

This might not be the right group for this question, since its kind of
a pure html question...

Given the html construct:

<form action='index.php?expand=0,10000' method='post'>
Email: <input type='text' name='login[email]' size='30'/>
Password:<input type='password' name='login[passwd]' size='30'/>
</form>

I'm trying to construct a url so that the form values are posted in the
url...

I.e, something like:
http://www.acme.com/index.php?expand0,10000&login[email]=j**@mail.com&login[passwd]=secret1234

.... but since the form values to receive the values looks like an
array(??) this doesn't seem to work.

Just wondering if anyone could give me some hints on what I'm doing
wrong here.

Thanks for any comments.

/Brian

Sep 28 '05 #1
6 10776
br*************@yahoo.com wrote:
This might not be the right group for this question, since its kind of
a pure html question...

Given the html construct:

<form action='index.php?expand=0,10000' method='post'>
Email: <input type='text' name='login[email]' size='30'/>
Password:<input type='password' name='login[passwd]' size='30'/>
</form>

I'm trying to construct a url so that the form values are posted in the
url...

I.e, something like:
http://www.acme.com/index.php?expand0,10000&login[email]=j**@mail.com&login[passwd]=secret1234

... but since the form values to receive the values looks like an
array(??) this doesn't seem to work.

Just wondering if anyone could give me some hints on what I'm doing
wrong here.

Thanks for any comments.

/Brian


For a post operation, the incoming data will be in the $_POST variable.

In your case you are using the id's "login[email]" and "login[passwd]',
so your values will be in the array as $_POST['login']['email'] and
$_POST['login]['passwd]

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 28 '05 #2
Hi and thanks for the tip. However, I'm having a bit of a puzzle trying
to figure out how one can post these variable via the url like:

http://www.acme.com/page.php?user=joe&passwd=secret1234

Any ideas?
Jerry Stuckle wrote:
For a post operation, the incoming data will be in the $_POST variable.

In your case you are using the id's "login[email]" and "login[passwd]',
so your values will be in the array as $_POST['login']['email'] and
$_POST['login]['passwd]

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Sep 28 '05 #3

br*************@yahoo.com wrote:
Hi and thanks for the tip. However, I'm having a bit of a puzzle trying
to figure out how one can post these variable via the url like:

http://www.acme.com/page.php?user=joe&passwd=secret1234

Any ideas?


use GET instead opf POST

micha

Sep 28 '05 #4
br*************@yahoo.com wrote:
Hi and thanks for the tip. However, I'm having a bit of a puzzle trying
to figure out how one can post these variable via the url like:

http://www.acme.com/page.php?user=joe&passwd=secret1234

Any ideas?
Jerry Stuckle wrote:
For a post operation, the incoming data will be in the $_POST variable.

In your case you are using the id's "login[email]" and "login[passwd]',
so your values will be in the array as $_POST['login']['email'] and
$_POST['login]['passwd]

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================



Brian,

This example is a GET operation (VERY insecure - especially where userid
and passwords are concerned); For that you would use the $_GET array.

The basic differences are:

When a form's method is GET, the values in the form are sent in the URL
(as above) and you use $_GET to access them (in your case, $_GET['user']
would contain 'joe', and $_GET['passwd'] would contain 'secret1234');

Conversely, when a form's method is POST, the values are passed by the
browser but not in the URL. There you would use $_POST, i.e.
$_POST['user'] and $_POST['passwd'].

GET operations are nice for some things because the user can bookmark
the request and return to the same page with the same parameters.
However, the user can also change those parameters before submitting the
page, so it's less secure.

POST, OTOH, doesn't allow the user to bookmark the page *with the posted
parameters*. He/she can only bookmark the URL itself, and any POST
parameters are not available when he/she later tries to use the
bookmark. It is, however, more secure because the user can't as easily
change the parameters before submitting the page.

Another problem with POST is that you can't easily pass these parameters
on if you should need to redirect the user to a new page. But I
recommend you don't worry about that right now; just keep it in mind and
ask more questions later when you need to redirect the user with parameters.

Also, if you have a lot of data on your form, the GET url can become
quite unwieldy. POST urls, OTOH, only contain the URL of the page, so
are shorter.

Personally, I prefer to use POST when possible.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 28 '05 #5
Jerry Stuckle wrote:
br*************@yahoo.com wrote:
Hi and thanks for the tip. However, I'm having a bit of a puzzle trying
to figure out how one can post these variable via the url like:

http://www.acme.com/page.php?user=joe&passwd=secret1234

Any ideas?
Jerry Stuckle wrote:
For a post operation, the incoming data will be in the $_POST variable.

In your case you are using the id's "login[email]" and "login[passwd]',
so your values will be in the array as $_POST['login']['email'] and
$_POST['login]['passwd]

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================



Brian,

This example is a GET operation (VERY insecure - especially where userid
and passwords are concerned); For that you would use the $_GET array.

The basic differences are:

When a form's method is GET, the values in the form are sent in the URL
(as above) and you use $_GET to access them (in your case, $_GET['user']
would contain 'joe', and $_GET['passwd'] would contain 'secret1234');

Conversely, when a form's method is POST, the values are passed by the
browser but not in the URL. There you would use $_POST, i.e.
$_POST['user'] and $_POST['passwd'].

GET operations are nice for some things because the user can bookmark
the request and return to the same page with the same parameters.
However, the user can also change those parameters before submitting the
page, so it's less secure.

POST, OTOH, doesn't allow the user to bookmark the page *with the posted
parameters*. He/she can only bookmark the URL itself, and any POST
parameters are not available when he/she later tries to use the
bookmark. It is, however, more secure because the user can't as easily
change the parameters before submitting the page.

Another problem with POST is that you can't easily pass these parameters
on if you should need to redirect the user to a new page. But I
recommend you don't worry about that right now; just keep it in mind and
ask more questions later when you need to redirect the user with
parameters.


What a good explanation!

I see the the OP is apparently dealing with a login. This immediately
raises the question of validation of the posted values and of course the
need to indeed pass variables created by the post method. The answer
lies of course in the use of cookies, or much preferably, sessions.

Louise
Sep 28 '05 #6
brian_mckracken wrote:
I'm trying to construct a url so that the form values are posted in the
url...


http://www.w3.org/2001/tag/doc/whenToUseGet.html

--
Jock
Sep 30 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Rafi Kfir | last post: by
9 posts views Thread by sathya | last post: by
11 posts views Thread by Geoff Cox | last post: by
8 posts views Thread by nescio | last post: by
13 posts views Thread by sathyashrayan | last post: by
6 posts views Thread by new2coding | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.