Hi there,
I'm trying to pass info from a "Drop list" in an .html form into a .php which will then query a database. It doesn't work and I wondered if I'm missing something easy? If I junk the dropdown list and just put a "textfield" there is no problem but I want to have the fixed choices list. Here is the code:-
<form id="form1" name="form1" method="post" action="bindex.php">
<p>
<select name="firstname" id="firstname">
<option value="Colin" selected="selected">Colin</option>
<option value="Christophe">Christophe</option>
<option value="Neill">Neill</option>
<option value="Robbie">Robbie</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
<p> </p>
</form>
.....and the Php code....
$dbcnx = @mysql_connect('localhost', 'mydb', 'mypassword');
if (!$dbcnx){
echo ('<p>Unable to connect to the server at this time.</p>');
exit();
}
// Select birthday database
mysql_select_db('mydb', $dbcnx);
if (!@mysql_select_db('mydb')){
exit('<p>Unable to connect to database at this time.</p>');
}
//check value
$result = mysql_query("SELECT * from birthdays WHERE firstname='$firstname' ");
$worked = mysql_fetch_array($result);
$firstname = $worked[firstname];
$lastname = $worked[lastname];
$birthday = $worked[birthday];
if($worked){
echo " $firstname $lastname, $birthday ";
}
?>
Anyone any ideas? Thanks in advance
Fat Colin