Am trying to do two things on a page, retrieve db info and display it through a $_GET which I'm functionally able to do on a product details page (details.php?id=7). I'm also trying to populate hidden fields in the Paypal hidden form. Through error messages I know I'm not declaring the variables correctly. I've done searches but have been unable to find what I'm doing wrong in this scenario. Can someone please assist.
Strangely, I was able to get the page without error, but not with the results I wanted. All I'm looking to do is have variables (Price and Name) from a query populate a form's hidden fields. Here are some of the changes I made to get it to not error.
Here's what I'm getting on the processed code:
<input type="hidden" name="item_number" value="2">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="amount" value="">
Thanks in advance.
if(isset($GET['Prodid']) && !empty($GET['Prodid'])){
$Prodid = $GET['Prodid'];
$Name = isset($POST['Name']) ? $POST['Name'] : "";
$Price = isset($POST['Price']) ? $POST['Price'] : "";
//$Name = $POST['Name'];
//$Price = $POST['Price'];
$query = "SELECT Prodid, Name, Category, Size, Description, Price
FROM testdb
WHERE Prodid = '".$GET['Prodid']."'
AND Status = 'A'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
} else {
echo "Cannot find the product ID or product ID is empty.";
}
?>
<table border ="2">
<?php
echo '<tr><td>Prodid</td><td>Name</td><td>Description</td><td>Size</td><td>Category</td><td>Price</td></tr>';
$cols = mysql_num_fields( $result );
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['Prodid']."</td>";
echo "<td>".$row['Name']."</td>";
echo "<td>".$row['Description']."</td>";
echo "<td>".$row['Size']."</td>";
echo "<td>".$row['Category']."</td>";
echo "<td>".$row['Price']."</td>";
echo "</tr>";
}
?>
</table>
<form target="paypal" action="https://www.paypal...." method="post">
<table>
<tr>
<input type="hidden" name="item_number" value="<?php Print $Prodid;?>">
<input type="hidden" name="item_name" value="<?php Print $Name;?>">
<input type="hidden" name="amount" value="<?php Print $Price;?>">
</form>