if elseif PHP Script problem

Hi, I have a script to email hotel reservation requests. There are several hotels that share the same values and most of them use a general request email form I will call hotel-request. A few hotels have somewhat different values that do not conform to the standard / regular form hotel-request, so I have to include separate email forms for them like, hotel-one, hotel-two and so on. My problem is that if I want to request a hotel with a specific name like hotel-one, the script is sending both form emails (hotel-request and hotel-one) Could you please help me correct this?

Here is part of the script:

case "reservation_request":
				
				        
                        include_once(LEVEL."inc/emailer/emailer.php");
						
                        if($_POST["form_type"] == "hotel-one"){
                                SendEmail("hotel-one-request", $_POST);
                        }
						
						
						elseif($_POST["form_type"] == "hotel-two"){
                                SendEmail("hotel-two-request", $_POST);
                        }
						
						elseif($_POST["form_type"] == "hotel-three"){
                                SendEmail("hotel-three-request", $_POST);
                        }
						
						
						elseif($_POST["form_type"] == "hotel-four"){
                                SendEmail("hotel-four-request", $_POST);
                        }
	
		
						
                        else {
                                SendEmail("hotel-request",$_POST);
								
                        }

Open in new window




Thanks,

Jorge
Jorge BatresAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
There's nothing wrong with the code you've posted, so I'm guessing that there's something wrong with the code that you haven't.

It looks like you're using a switch, so you need to make sure you call 'break' at the end of each case, otherwise the code will 'drop through'

case "reservation_request":
    // do something
    break; // without this the following case would also fire 

case "something_else":
    // do something else
    break;

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jorge BatresAuthor Commented:
Thank you Chris! inadvertently I deleted the "break" line from the script.

Thanks again,

Jorge
0
Chris StanyonWebDevCommented:
Haha - been there ... done that :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.