...

View Full Version : Adding a PHP Value to a Form



evesham
06-19-2006, 06:38 PM
Hello,

I'd like to add a PHP value into the value field of a form which will then be sumitted to process via memberlist.php. The field is hidden. How do i add PHP code to a form as this doesn't currently work:


<FORM METHOD="POST" ACTION="memberlist.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo $row['username']; ?></td>
<td><input type="text" name="userquery" value="'<?php $row['username']; ?>'"></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>

The PHP/SQL code then loops around.

Thanks

rlemon
06-19-2006, 07:21 PM
to 'print' or 'echo' the code you need to call it out as that



<FORM METHOD="POST" ACTION="memberlist.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo $row['username']; ?></td>
<td><input type="text" name="userquery" value="'<? print $row['username']; ?>'"></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>


instead of print you can also use echo

echo $row['username']

lavinpj1
06-19-2006, 07:25 PM
or, as a point of interest, = e.g.

<?php= $row['username']; ?>

~Phil~

evesham
06-19-2006, 07:30 PM
to 'print' or 'echo' the code you need to call it out as that



<FORM METHOD="POST" ACTION="memberlist.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo $row['username']; ?></td>
<td><input type="text" name="userquery" value="'<? print $row['username']; ?>'"></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>


instead of print you can also use echo

echo $row['username']Thanks, Great help both of you dudes!

rlemon
06-19-2006, 07:54 PM
or, as a point of interest, = e.g.

<?php= $row['username']; ?>

~Phil~

didn't want to confuse him/her



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum