/    Sign up×
Community /Pin to ProfileBookmark

PHP form with drop down list

Hi,
I have been unable to resolve my problem regarding the drop down menu on the form. I have never used PHP and MySQL before and never been programming before.
User is supposed to select option from drop down list lets say Option1, select dates From – To and when Submited redirected to Option1.php. When user selects Option2 redirected to Option2.php etc. It all works fine however i cannot pass the values for dates fields. I cannot even echo the dates on Option1.php page. It is not remembering the value of dates fields.

My index.html:

<?php
if(isset($_POST[‘menu’])){
$menu = $_
POST[‘menu’];
header(“Location:$menu”);}
?>
<head>
<script type=”text/javascript” src=”calendar.js” language=”javascript”></script>
</head>
<body onload=”date_selector.init(window.document.forms[‘mainselec’]);”>
<form name=”mainselec” method=”post” action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>”>
<select name=”menu”>
<option value=””></option>
<option value=”Option1.php”>1 Selected</option>
<option value=”Option2.php”>2 Selected</option>
</select>
<table><tr><td>
<input type=”button” value=”From” onclick=”date_selector.showDateSelector(‘minimumDate’);”>
<input type=”text” name=”minimumDate” value=”DD/MM/YYYY”>
<input type=”button” value=”To” onclick=”date_selector.showDateSelector(‘maximumDate’);”>
<input type=”text” name=”maximumDate” value=”DD/MM/YYYY”>
</td></tr></table>
<input type=”submit” name=”submit” value=”Submit”>
</form>
</body>
</html>

My Option1.php
<?php
echo $minimumDate;
echo $maximumDate;
?>

Please if anyone knows how this can be resolved i would really apprieciate it.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 16.2010 — I'm guessing maybe what you want to do is include() the file instead of doing a header() redirect.
[code=php]
<?php
if(isset($_POST['menu'])){
$menu = basename($_POST['menu']); // use basename() to stop directory injection
if(file_exists($menu) and is_readable($menu))
{
include $menu;
exit;
}
echo "<p class='error'>Invalid selection '$menu'</p>n";
}
// . . . rest of script . . .
?>
[/code]
×

Success!

Help @adBH 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 5.29,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...