I have wrote a script to query my mysql database based up a name that is selected from an HTML list menu, the form action calls to my php script from my html doc, I have tested connectivity to the databse and have added a manual sql query to my php script to be sure it is functioning properly, the problem is I'm not sure how to get the script to see what option the html form is sending, I thought I could use:
$query = "SELECT * FROM table WHERE email = '{$_GET['selecteduser']}@mydomain.com'";
but that doesn't seem to be working properly. Maybe the HTML document is sending it correctly? Here is my form:
<form action="report_results.php" method="post">
<select name="selecteduser">
<option value="selecteduser">Select One:</option>
<option value="user1@mydomain.com">user1</option>
<option value="user2@mydomain.com">user2</option>
</select>
<input type="submit" name="submit" value="Go!">
</form>
This form calls to the php script which then takes the input from the HTML form and processes it into the $_GET query and sends it to the while loop in the script, I'm not sure why this is not working? Here is my php code:
<?php
$db = mysql_connect("localhost", "sqluser", "sqlpasswd") or die("Could not connect to Mysql");
if (!$db == False)
{
mysql_select_db("mydb");
$query = "SELECT * FROM table WHERE email = '{$_GET['selecteduser']}@mydomain.com'";
$result = mysql_query($sql,$db);
while ($row = mysql_fetch_row($result))
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}
mysql_close($cn);
}
else
{
print "Problem Connecting to the Database<br>";
}
?>
Does anyone have any suggestions??
Thanks