# php form action types

Page 1 of 1

## 6 Replies - 1726 Views - Last Post: 15 May 2011 - 07:13 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=232091&amp;s=be4603c332d0d1b14c01064548747373&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 menukadevinda

• D.I.C Regular

Reputation: -7
• 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

• jaVanir

Reputation: 1013
• 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

• D.I.C Regular

Reputation: -7
• 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

• jaVanir

Reputation: 1013
• 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

• D.I.C Regular

Reputation: -7
• 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

• jaVanir

Reputation: 1013
• 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

• Saucy!

Reputation: 6241
• Posts: 24,009
• 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

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}