Quick PHP question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josboogz
Forum Newbie
Posts: 12
Joined: Thu Feb 06, 2003 5:05 am

Quick PHP question

Post by josboogz »

Hi all,

Was just wondering when posting a variable such as

<input name="" id="hidden" value="">

is it possible to obtain the id value similar to getting the name and value in the page that it is posted too?


Thanks for your time


Jose
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

i dont understand the question.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yes it is possible to get variables from hidden form elements.

Here is an example:

Code: Select all

&lt;form action="" method="post"&gt;
&lt;input name="hidden" type="hidden" value="this is the hidden variable"&gt;
&lt;input type="submit" name="submit" value="Get the hidden variable"&gt;
&lt;/form&gt;
On the same page add the following within the body of the page:

Code: Select all

<?php
if ($submit){
echo "$hidden";
}
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can't get the id attribute value through PHP because all that's in $_POST (or $_GET) is the name and value attribute information.

Why do you need the id as well?

Mac
Post Reply