Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What php code when a drop down menu is used?

Status
Not open for further replies.

colinrichard

Programmer
Apr 18, 2009
1
I want a registration page on my website where the user clicks on the appropriate item from a dropdown menu. I’ve simplified things so as to isolate the one operation I can’t do – I mean that the $hour variable, the username, the password, I can record all those in a record set – but I can’t record the user’s answer to the question “In what month were you born?” I can’t do so because, in answer to this question, the user is just going to click on the appropriate month from a dropdown list – Great! But then what variable am I going to insert into the ‘splut’ table on the ‘debra’ database? I know that it’s easy for you geeks but very hard for me, an old-timer newbie! Any help will be greatly appreciated

Here's my code:

<?php
session_start();
$hour=time();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Untitled Document</title>
</head>
<?
mysql_connect("localhost","root","1234");
mysql_db_query("debra","SET NAMES utf8");


mysql_query("insert INTO splut (start_time , user , passwd) VALUES (NOW() , '$user', '$pw')") or die(mysql_error());

if(mysql_query($sql)){
echo "OK";
}else{
echo "";
}
?>
<body>

<form>
Username:
<input type = "text" name="user" method="post" />
<br /><br />
Password:
<input type = "password" name="pw" method="post" />
<br /><br />
<input type = "submit" name="submit" value="SUBMIT" />

<p>
<label>In what month were you born?: &nbsp;&nbsp;</label>

<select name="month" style="width: 75px;">
<option value='' selected>Month</option>

<option value='01' >January</option>
<option value='02' >February</option>
<option value='03' >March</option>
<option value='04' >April</option>
<option value='05' >May</option>
<option value='06' >June</option>
<option value='07' >July</option>
<option value='08' >August</option>
<option value='09' >September</option>

<option value='10' >October</option>
<option value='11' >November</option>
<option value='12' >December</option>

</select>

</form>
<!-- END PAGE CONTENT -->

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top