I'm using a form with a dropdown list. When the user select "Test1" in the dropdown then press the button "Submit" it has to send the data to www.test1.com.

When the user select "Test2" in the dropdown then press the button "Submit" it has to send the date to www.test2.com.

Also the data they've filled in has to come with.

I'm working with a datacheck.php, so when the press submit it post to datacheck.php and there I have following code:


if(isset($_POST['TEST1']) && $_POST['TEST1']== 'Y'){
header("Location: http://mysite.com/sage/page1.php");
else {
header("Location: http://mysite.com/sage/page2.php");

But it doesnt work, it goes directly to page2.php even when I've selected Test1 in the dropdown.

Does anyone has an idea?


I think you need to submit form using javascript, base-on your selection you fire some javascript function & than you make condition base-on your selection & write code for submit form.

That's correct but I'm not able to find it :)

Member Avatar


If you don't want to use js - simply have a general form handler file, e.g. handler.php

The form sends everything to that. Say the dropdown has a name of "myselect" and the values could be "first", "second" or "third" (just an example) you could do:

 case "first":

 case "second":

 case "third";

Of course this will only work (include) if the form page is in the same domain and the pages are only there to process the data. If the pages contain full html pages. No, it won't be appropriate.

Please try this as per your code:

make javascript function in your selection box.


<script type="text/javascript" language="JavaScript">

function funRedirect(obj) {

 if (obj.value == 'Test1')
     document.location.href ="www.test1.com";
    document.location.href ="www.test2.com";