Can someone look at this and tell my why it's not working like it should? It gets the data from the database fine, just wont post to search.php
<?php
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","root",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("test1") or die("Unable to select database"); //select which database we're using
$sql="SELECT LastName, FirstName FROM persons";
$result=mysql_query($sql);
$optionsfname="";
$optionslname="";
while ($row=mysql_fetch_array($result)) {
$id=$row["ID"];
$fname=$row["FirstName"];
$lname=$row["LastName"];
$optionsfname.="<OPTION VALUE=\"$id\">".$fname.'</option>';
$optionslname.="<OPTION VALUE=\"$id\">".$lname.'</option>';
}
?>
<form action="search.php" method="GET">
<select name="name">
<OPTION VALUE=0>First Name
<?=$optionsfname?>
</SELECT>
<input type="Submit" value="Search"/>
</form>
search.php
<?php
// Get the search variable from URL
$varfname = @$_GET['fname'] ;
$varname = @$_GET['name'] ;
$trimmedfname = trim($varfname);
$trimmedname = trim($varname); //trim whitespace from the stored variable
// rows to return
$limit=50;
// check for an empty name and display a message.
if ($trimmedname == "")
{
echo "<p>A last name is required...</p>";
exit;
}
When I click submit it gives me the message A last name is required.