passing a php variable by html button value

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
lubber123
Forum Commoner
Posts: 51
Joined: Mon Sep 15, 2008 12:26 pm
Location: Manassas, VA

passing a php variable by html button value

Post by lubber123 »

Hi, I am trying to post a hidden field php value to another php page. If I simply assign a value to the hidden field it works fine - so I know that part works fine. The problem occurs when i try to send the PHP variable - it nothing displays from the other page.

Here is the code:

Code: Select all

 
<form name="formemail" method="post" action="functions/test.php">   
    <?php $output = "testing_the_variable"; ?>
    
    <input type="hidden" name="hiddenfield" id="hiddenfield" value= "<?php $output; ?> " 
 
      <p><input type="submit" value="Email This Event" id="button"  />
      
     </form>
 
What am I doing wrong? It should be so simple.
User avatar
Kastor
Forum Newbie
Posts: 24
Joined: Thu May 01, 2008 2:29 am
Location: Grodno, Belarus
Contact:

Re: passing a php variable by html button value

Post by Kastor »

Code: Select all

 
<input type="hidden" name="hiddenfield" id="hiddenfield" value="<?=$output?>"/>
 
ahowell
Forum Newbie
Posts: 17
Joined: Mon Sep 01, 2008 9:18 pm

Re: passing a php variable by html button value

Post by ahowell »

You need to echo the value to the markup.

Code: Select all

<input type="hidden" name="hiddenfield" id="hiddenfield" value="<?php [color=#FF0000]echo[/color] $output?>" />
or

Code: Select all

<input type="hidden" name="hiddenfield" id="hiddenfield" value="[color=#FF0000]<?=[/color]$output?>" />
<?= is a shortcut for directly outputing a variables value.
Post Reply