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":
                        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 {

Open in new window


Jorge BatresAsked:
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
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

Open in new window

Jorge BatresAuthor Commented:
Thank you Chris! inadvertently I deleted the "break" line from the script.

Thanks again,

Chris StanyonCommented:
Haha - been there ... done that :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.