Post array values (beginner's question)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brian_mckracken@yahoo.com

    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.p hp?expand=0,100 00' 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?expan d0,10000&login[email]=joe@mail.com&l ogin[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

  • Jerry Stuckle

    #2
    Re: Post array values (beginner's question)

    brian_mckracken @yahoo.com wrote:[color=blue]
    > 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.p hp?expand=0,100 00' 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?expan d0,10000&login[email]=joe@mail.com&l ogin[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
    >[/color]

    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.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • brian_mckracken@yahoo.com

      #3
      Re: Post array values (beginner's question)

      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:



      Any ideas?


      Jerry Stuckle wrote:[color=blue]
      > 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.
      > jstucklex@attgl obal.net
      > =============== ===[/color]

      Comment

      • chotiwallah

        #4
        Re: Post array values (beginner's question)


        brian_mckracken @yahoo.com wrote:[color=blue]
        > 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?
        >
        >[/color]

        use GET instead opf POST

        micha

        Comment

        • Jerry Stuckle

          #5
          Re: Post array values (beginner's question)

          brian_mckracken @yahoo.com wrote:[color=blue]
          > 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:
          >[color=green]
          >>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.
          >>jstucklex@att global.net
          >>============= =====[/color]
          >
          >[/color]

          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.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • boclair

            #6
            Re: Post array values (beginner's question)

            Jerry Stuckle wrote:[color=blue]
            > brian_mckracken @yahoo.com wrote:
            >[color=green]
            >> 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:
            >>[color=darkred]
            >>> 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.
            >>> jstucklex@attgl obal.net
            >>> =============== ===[/color]
            >>
            >>
            >>[/color]
            >
            > 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.[/color]

            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

            Comment

            • John Dunlop

              #7
              Re: Post array values (beginner's question)

              brian_mckracken wrote:
              [color=blue]
              > I'm trying to construct a url so that the form values are posted in the
              > url...[/color]



              --
              Jock

              Comment

              Working...