Jump to content

If Statements around Forms, help needed


ltoto

Recommended Posts

Basically what I have got so far is an Initial Enquiry Form. And on this enquiry form there is a drop down list where you can select either 'hotel', 'villa' or ' golf', along with other information.
When this is selected it goes to another page with the the form that has been selected on 'hotels', 'Villas' and 'golf'. ( hope this is making sense so far.

This is the code used to do this.

[code]header("Location:index.php?Id=18&type=".$_POST['selectType']);[/code]

so i have three forms on one page, but if that form is not selected, i do not want to to show up on the pagee.g

if hotel is selected in the dropdown menu from the initial enquiry form, i would not want the villa or golf form to appear.

so what i want to know is what i have to put around each of the forms so they only show up if selected, , i would guess something like:

so if the site = " golf " show the gold form on index?Id=18


obviously with out the english


any suggestions?
Link to comment
https://forums.phpfreaks.com/topic/21435-if-statements-around-forms-help-needed/
Share on other sites

it would be easier to use javascript (google it) but you can do it in php a much longer way. (could google this too).

<?php

// LETS CALL YOUR DROP DOWN 'place' //
// SO IT'D BE SOMETHING LIKE THIS //
$page = $_POST['page']

if($page == 'hotel'){

  // SHOW THIS FORM //

} else if($page == 'villa'){

  // SHOW THIS FORM //

} else if($page == 'golf'){

  // SHOW THIS FORM //

} else {

  // DEFAULT FORM //

}

?>

something like that should work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.