Page 1 of 1

newbie question about sending hidden form field

Posted: Wed Mar 03, 2010 8:05 am
by churd
I am trying to send the variable "userid" via a hidden form field on a php page... I know that if I type:

Code: Select all

<?PHP print 'userID: '.$user->userID.'<br />'; ?>
it successfully outputs the userID assigned to the user (it's pulled from a get_session() function).

However, I am stumped in terms of translating that into sending that variable via a hidden form field:

Code: Select all

<input type="hidden" name="userid" value="<?php $userID ?>" />
The "value=" part is where I'm stuck.

Please help a newb! :arrow: :|

Re: newbie question about sending hidden form field

Posted: Wed Mar 03, 2010 8:51 am
by superdezign
In your second example, you don't use "print" or "echo". Therefore, nothing will be output from that block of PHP code.

Also, in your first example, you use "$user->userID". In your second example, you use "$userID". Are you sure you didn't mean to use "$user->userID" in the second example, instead?

Re: newbie question about sending hidden form field

Posted: Wed Mar 03, 2010 9:04 am
by churd
superdezign wrote:In your second example, you don't use "print" or "echo". Therefore, nothing will be output from that block of PHP code.

Also, in your first example, you use "$user->userID". In your second example, you use "$userID". Are you sure you didn't mean to use "$user->userID" in the second example, instead?
I tried the following:

Code: Select all

<?php print '$user->userID' ?>
and

Code: Select all

<?php print '.$user->userID.' ?>
This one worked!!:

Code: Select all

<?php print $user->userID ?>
(picks up his 800 page PHP+MySQL book and turns to page 10 labeled "Syntax")

Thanks for helping a newb :) ... I'm sure I'll have more questions.