Page 1 of 1

passing a php variable by html button value

Posted: Mon Sep 15, 2008 12:35 pm
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.

Re: passing a php variable by html button value

Posted: Mon Sep 15, 2008 2:06 pm
by Kastor

Code: Select all

 
<input type="hidden" name="hiddenfield" id="hiddenfield" value="<?=$output?>"/>
 

Re: passing a php variable by html button value

Posted: Mon Sep 15, 2008 2:10 pm
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.