troubleshooting Question

Sending PHP data with form

Avatar of brendan-amex
brendan-amex asked on
Web DevelopmentHTMLPHP
7 Comments1 Solution199 ViewsLast Modified:
I have a PHP page that pulls from a MySQL database and it displays everything perfectly. I now have added another field which is a form submit button that I have redirect to another page in order to echo the value I want. For some reason when the second php page loads it's blank. What am I doing wrong? Can PHP code be imbedded into an HTML form? My code is below.

And then here is my test.php page:

<?php
$select1 = $_POST['select1'];

echo $select1;
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th>Field 1</th>
<th>Field 2</th>
<th>Field 3</th>
<th>Delete Row</th>
</tr>
</table>

<table border="1" cellspacing="2" cellpadding="2">

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"Field1");
$f2=mysql_result($result,$i,"Field2");
$f3=mysql_result($result,$i,"Field3");

?>

<tr>
<td width="300"><font size="3" face="Calibri, Calibri, Calibri"><?php echo $f1; ?></font></td>
<td width="80"><font size="3" face="Calibri, Calibri, Calibri"><?php echo $f2; ?></font></td>
<td width="300"><font size="3" face="Calibri, Calibri, Calibri"><?php echo $f3; ?></font></td>

<td><form name="select1" form method="post" action="test.php">
<input type="hidden" id="select1" name="select1" value="<?php $f1; ?>" />
<input type="submit" name="submit" value="Submit" /></form></td>

</tr>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros