/    Sign up×
Community /Pin to ProfileBookmark

Drop-down menu – form submission

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 $_
POST[‘location’];?>
<?php echo $_POST[‘fromto’];?>
<?php echo $_
POST[‘leadership’];?>

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>
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@DurothFeb 18.2006 — So, all you want is a submit button? Or am I just being plain simple here?

In that case:
[code=php]<form method="POST" value="newpage.php">[/code]
should go into the <form> tag, and
[code=php]<input type="submit" value="Submit Info">[/code]
should go somewhere between the <form> and </form> tags.
×

Success!

Help @scottyrob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...