Hi folks. I have a drop-down menu populated by my database. Once the specific item has been selected in the menu it fills out the form. I would like it to have a submit button so that it submits this data to the other page where this code is waiting
<?php echo $_POST[‘attend’];?>
<?php echo $
<?php echo $_POST[‘fromto’];?>
<?php echo $
The code for the page with the drop down menu is as follows
[code=php]
<?php
$username = “cp”;
$password = “h1”;
$hostname = “localhost”;
$dbh = @mysql_connect($hostname, $username, $password) or die(“Unable to connect to MySQL”);
$selected = @mysql_select_db(“ls”, $dbh) or die(“Could not select database: ” . mysql_error());
$query_seminars = (‘SELECT * FROM `Permission_To_Camp`’);
$seminars = @mysql_query($query_seminars) or die(“Query failed: $query_seminars – ” . mysql_error());
$row_seminars = mysql_fetch_assoc($seminars);
$totalRows_seminars = mysql_num_rows($seminars);
$colname_chosen_seminar = “-1”;
if (isset($_POST[‘Attend’])) {
$colname_chosen_seminar = (get_magic_quotes_gpc()) ? $_POST[‘Attend’] : addslashes($_POST[‘Attend’]);
}
mysql_select_db($database_CHF_PHP, $dbh);
$query_chosen_seminar = sprintf(“SELECT * FROM Permission_To_Camp WHERE id = %s”, $colname_chosen_seminar);
$chosen_seminar = mysql_query($query_chosen_seminar, $dbh) or die(mysql_error());
$row_chosen_seminar = mysql_fetch_assoc($chosen_seminar);
$totalRows_chosen_seminar = mysql_num_rows($chosen_seminar);
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Untitled Document</title>
<script type=”text/javascript”>
function chkFrm(el){
if(el.selectedIndex == 0){
alert(“Please choose an option”);
return false
}
else{
el.form.submit();
}
}
</script>
</head>
<body>
<form name=”form1″ method=”post” action=””>
<p>
<select name=”Attend1″ onchange=”chkFrm(this)”>
<option value=”Choose” <?php if (!(strcmp(“Choose”, $_POST[‘Attend’]))) {echo “SELECTED”;} ?>>Choose Form</option>
<?php
do {
?>
<option value=”<?php echo $row_seminars[‘ID’]?>”<?php if (!(strcmp($row_seminars[‘ID’], $_POST[‘Attend’]))) {echo “SELECTED”;} ?>><?php echo $row_seminars[‘Attend’]?></option>
<?php
} while ($row_seminars = mysql_fetch_assoc($seminars));
$rows = mysql_num_rows($seminars);
if($rows > 0) {
mysql_data_seek($seminars, 0);
$row_seminars = mysql_fetch_assoc($seminars);
}
?>
</select>
</p>
<p>Attend The:
<input name=”attend” type=”text” value=”<?php echo $row_chosen_seminar[‘Attend’]; ?>”>
<br>
<p>Location:
<input name=”location” type=”text” value=”<?php echo $row_chosen_seminar[‘Location’]; ?>”>
<br>
From – To:
<input name=”fromto” type=”text” value=”<?php echo $row_chosen_seminar[‘Fromto’]; ?>”>
<br>
Under the leadership of:
<input name=”leadership” type=”text” value=”<?php echo $row_chosen_seminar[‘Leadership’]; ?>”>
<br>
<br>
</p>
</form>
</body>
</html>