php 3rd elseif dropdown

greetings
i have the following code which works without the 3rd elseif. Although i would like to add a 3rd elseif which says echo “please select a server and date when you try to submit a choice from dropdown 1 and 2
so submitting the form when selecting from dropdown menu and menuic should give a message as not allowed”

[php]if (isset($_POST[“menu”]) and ($_POST[“date”])){
//echo $_POST[“menu”]."
";
//echo $_POST[“date”];
header(“Location: http://” . $_POST[“menu”] . $_POST[“date”] . “.html”);
}elseif(isset($_POST[“menufic”]) and ($_POST[“date”])){
header(“Location: http://” . $_POST[“menuic”] . $_POST[“date”] . “.html”);
}elseif(isset($_POST[“menufic”]) and ($_POST[“date”])){
echo “please select a server and date…]n”;
?>[/php]

Try this:
[php]
if ( isset($_POST[“menu”]) and ($_POST[“date”]) ){
//echo $_POST[“menu”]."
";
//echo $_POST[“date”];
header(“Location: http://” . $_POST[“menu”] . $_POST[“date”] . “.html”);
}elseif( isset($_POST[“menufic”]) and ($_POST[“date”]) ){
header(“Location: http://” . $_POST[“menuic”] . $_POST[“date”] . “.html”);
}elseif( !isset($_POST[“menufic”]) OR (!isset($_POST[“date”])) ){
echo “please select a server and date…]n”;
?>
[/php]
If they are both set do the redirect. If one is missing give the message…
(Not tested, just explaining…)

hi Ernie
i tried that but i still am able to submit if i select a choice from echo of the 3 dropdowns. I tried this to but it still gets submitted.

[php]}elseif(isset($_POST[“menu”]) and ($_POST[“menufic”]) and ($_POST[“date”]){
echo “no good”;
}
[/php]

Okay, Bishop, let me understand what you want.

You have three drop-downs. One MENU, one MENUFIC and one DATE.

If the user Selects MENU and DATE it goes somewhere.
If the user Selects MENUFIC and DATE it goes somewhere.
ELSE it displays, correct?

Or is there more to that list? I will get ya sorted out…

ok so

  • the user selects menu and date and it works which is good.
    or
  • the user selects menufic and date and it works which is good.
    or
  • the user selects menu, menufic and date and submits and it goes through which i dont want.
    whenever a choice from all 3 dropdowns tries to get submitted then it should not work, should just refresh the page or say “not valid …”

i tried this which i thought would do it be no luck:
[php]}elseif(isset($_POST[“menu”]) and ($_POST[“menufic”]) and ($_POST[“date”]){
echo “no good”;
}[/php]

Okay, so the extra or third option was if they select both the menus.

So, try this:
[php]
if ( isset($_POST[“menu”]) and !isset($_POST[‘menufic’]) and ($_POST[“date”]) ){
//echo $_POST[“menu”]."
";
//echo $_POST[“date”];
header(“Location: http://” . $_POST[“menu”] . $_POST[“date”] . “.html”);
}elseif( isset($_POST[“menufic”]) and !isset($_POST[‘menu’]) and ($_POST[“date”]) ){
header(“Location: http://” . $_POST[“menuic”] . $_POST[“date”] . “.html”);
}else{
echo “please select a server and date…]n”;
[/php]
The problem is you can not just check on the first option for menu set and date set.
That will also be true if all three are set.
And, the number two test can not just check on the menufic and date set as
this will also be true if all three are set.

SO, to solve it, you have to check for these three:
menu set menufic not-set date set
menufic set menu not-set date set
any other combo is fine for the error…

Should work, let us know…

that did. awesome. thanks. curious about one thing. since i have my php on the top of the page and my forms beneath that, how can i get that "[ please select a server and date…] message to be displayed in the body right under the forms rather than at the top of my page.?

html please select a server and date message appears up here
php
body
form form form
id like the please select a server and date message to appear here.

Well, I would do it this way:
[php]
$message = “”;
if ( isset($_POST[“menu”]) and !isset($_POST[‘menufic’]) and ($_POST[“date”]) ){
//echo $_POST[“menu”]."
";
//echo $_POST[“date”];
header(“Location: http://” . $_POST[“menu”] . $_POST[“date”] . “.html”);
}elseif( isset($_POST[“menufic”]) and !isset($_POST[‘menu’]) and ($_POST[“date”]) ){
header(“Location: http://” . $_POST[“menuic”] . $_POST[“date”] . “.html”);
}else{
$message = “please select a server and date…]n”;
}
[/php]
What this will do is if they pick the correct two, the page gets redirected to other pages.
Then, just display the message wherever you wish using <?PHP echo $message; ?>
Or, even better, just hard code it.

Okay, I think the logic is messed up. If the page redirects, all okay.
If not, you just want it to continue with the rest of the page. So, you don’t really even need
the last ELSE. You always want to tell them to pick a server and date. When they do, it goes
to the redirected page. Correct?

Sometimes trying to figure out someone else’s logic on page and user input flow is hard to do…
LOL… So, this one is solved, right?

Sponsor our Newsletter | Privacy Policy | Terms of Service