newbie question about sending hidden form field

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
churd
Forum Newbie
Posts: 8
Joined: Tue Feb 09, 2010 7:44 pm

newbie question about sending hidden form field

Post 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: :|
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: newbie question about sending hidden form field

Post 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?
churd
Forum Newbie
Posts: 8
Joined: Tue Feb 09, 2010 7:44 pm

Re: newbie question about sending hidden form field

Post 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.
Post Reply