I'm trying to use HTML form data in a MySQL query. If I require the information to be typed into the form, everything works fine:
<form action = "<?php echo $PHP_SELF ?>" method = "POST">
<input type = "text" name = "Hostessname">
<input type = "submit" value = "Hostess">
<?php
$query1 = "SELECT * FROM Products,Inventory_transactions,Show_info_access, Sales_consultants WHERE
Products.ProductID = Inventory_transactions.ProductID AND
Inventory_transactions.ConsultantID = Sales_consultants.ConsultantID AND
Inventory_transactions.ShowID = Show_info_access.ShowID AND
Show_info_access.Hostess = '$_POST[Hostessname]'
ORDER BY Products.SKU";
However, I'd like my form data to come from a list box. The following script successfully creates the list box, but when I submit my selection, I get an error (The requested URL /< was not found on this server).
<?php
$query_hostess = "SELECT DISTINCT Hostess FROM Show_info_access ORDER BY Hostess";
$result_hostess = mysql_query ($query_hostess) or die ("Couldn't find hostess");
echo "<form action = '<?php echo $PHP_SELF ?>' method = 'POST'>
<select name = 'Hostess'>\n";
while ($row = mysql_fetch_array($result_hostess))
{
extract($row);
echo "<option value = '$Hostess'>$Hostess\n";
}
echo "</select>\n";
echo "<input type = 'submit' value = 'Select Hostess'>
</form>\n";
$query1 = "SELECT * FROM Products,Inventory_transactions,Show_info_access, Sales_consultants WHERE
Products.ProductID = Inventory_transactions.ProductID AND
Inventory_transactions.ConsultantID = Sales_consultants.ConsultantID AND
Inventory_transactions.ShowID = Show_info_access.ShowID AND
Show_info_access.Hostess = '$_POST[Hostess]'
ORDER BY Products.SKU";
I'm new to PHP and I assume I must be making a pretty basic error. I hope someone can enlighten me!