Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning a hidden value to php var

Status
Not open for further replies.

oconv

Programmer
Jan 17, 2002
25
ZA
Hi all

I just want to find out if the following is possible :

<input type = &quot;hidden&quot; name = &quot;xxx&quot; value = &quot;hallo&quot;>
<?
$PhpVar = want to give it the value of xxx
?>


thanks
 
Yes, treat hidden fields as any other, ie text. In your example then variable $xxx would be created when the script posts/gets.
 
only if you do this:

<?$value=&quot;xxx&quot;;?>
<input type=hidden name=xpto value=&quot;$value&quot;>
//here you still have the $value with the value.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Anikin,

I think you misunderstood me.
I want to assign the value of hidden var xxx to a php var.
As phpPete has shown us , is the way to go.
What you did was to assign value xxx to a php var and then assign the php var to the value of the hidden var.

Another thing , if you want to assign (display) the value of a php var isn't the correct way
<input type = 'hidden' name = 'xxx' value = '<? echo $phpVar ?>'> ?
 
it's not possible to do in the same script. Cause hiddens are only set in the client and PHP runs in the server.

instead, if you do a GET or a POST of a form and the hidden is inside of it, it automaticaly sends the value to the PHP as $_POST['xxx'] or $_GET['xxx'] (deppending on the method used).

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top