6 Replies - 1273 Views - Last Post: 15 May 2011 - 07:13 AM Rate Topic: -----

#1 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

php form action types

Posted 15 May 2011 - 06:17 AM

hi,

i am newbie to php. I used form (in html)as follows in order to pass values.

<form action="index.php" method="post" name="frmPassword" id="frmPassword">


but when i refer the web i found that the following method also used to pass values.
i don't know how to use and what is the specialty in this method instead of previous one and when to use which method
second method is
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" name="frmPassword" id="frmPassword">



please help i googled couldn't get clear idea.

thx in advance
menuka

Is This A Good Question/Topic? 0
  • +

Replies To: php form action types

#2 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1011
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: php form action types

Posted 15 May 2011 - 06:23 AM

I am not sure what the problem is.
In both code examples you use the same method, POST.
You can read here how to properly use POST with an html form:
http://www.tizag.com/phpT/forms.php

But again, the problem as you described it was not clear (at least to me). If you can provide some more info about the problem, it would be much easier to help you.
Was This Post Helpful? 0
  • +
  • -

#3 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

Re: php form action types

Posted 15 May 2011 - 06:34 AM

hi,

i am sorry if i my english was not understandable to you.
here what i want to know is
why are there 2 formats of form.(i am not talking about POST and GET)
i mean in the fist method i referred action is
action="index.php"

but in the second method the action is
action="<?php echo $_SERVER['REQUEST_URI']; ?>"

i want to figure out the difference of this actions/ formats.

thx
Was This Post Helpful? 0
  • +
  • -

#4 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1011
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: php form action types

Posted 15 May 2011 - 06:43 AM

$_SERVER is an array containing data like paths, headers etc.
$_SERVER['REQUEST_URI'] is the URI (not url) given in order to get to this page.
so for example, this page's url is:
http://www.dreaminco...m-action-types/
and $_SERVER['REQUEST_URI'] contains
forums/topic/232091-php-form-action-types/

action doesn't specify the method but a uri.
so it is just a way of passing uri to action.
Was This Post Helpful? 1
  • +
  • -

#5 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

Re: php form action types

Posted 15 May 2011 - 06:59 AM

hi,

ok . then how does $_SERVER['REQUEST_URI']know where to submit the data?
it doesn't know any path. it is just a array.

thx
Was This Post Helpful? 0
  • +
  • -

#6 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1011
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: php form action types

Posted 15 May 2011 - 07:05 AM

$_SERVER is the array.
$_SERVER['REQUEST_URI'] has the uri.
so as I said, this page (your thread in the php forum on DIC) URL is
http://www.dreaminco...m-action-types/
However, if you could check the value of
$_SERVER['REQUEST_URI'], you could see that it is:
forums/topic/232091-php-form-action-types/
Now, since in the html form, action accepts URI, that is valid to pass it the value of $_SERVER['REQUEST_URI'].
Was This Post Helpful? 1
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6092
  • View blog
  • Posts: 23,612
  • Joined: 23-August 08

Re: php form action types

Posted 15 May 2011 - 07:13 AM

You need to learn how to find these answers for yourself through debugging. Use
var_dump($_SERVER)
and look at the contents.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1