Jump to content

on change select?


Yohanne

Recommended Posts

hi all.

i am new and i want to learn php and need somebody help.

 

could you help to find out the exact reason why it's not work.. it regards page cannot load using header.. take a look code ->

 

<form name = "form_branch_locator_" method = "GET" action = "<?php echo $_SERVER['REQUEST_UR'];?>">
<select name = 'GET_VALUE_REGION' onchange = 'this.form.submit()'>
<option value = "">Select Region</option>
<option value = "AR">All Region</option>
<option value = "NCR">National Capital Region</option>
<option value = "NL">Northern Luzon</option>
<option value = "SL">Southern Luzon</option>
<option value = "VI">Visayas</option>
<option value = "NM">Northern Mindanao</option>
<option value = "SM">Southern Mindanao</option>
</select>

<noscript><input type = "submit" name = "submit" value = "Search"></noscript>
<?php
if(isset($_GET["GET_VALUE_REGION"]) == "submit")
 {
 if(isset($_GET["GET_VALUE_REGION"]) == "NCR")
 {
 header("Location: aocs_ncr.php");
 exit();
 }
 if(isset($_GET["GET_VALUE_REGION"])== "NL")
	 {
	 header("Location: aocs_nl-pg.php");
	 exit();
	 }
	 if(isset($_GET["GET_VALUE_REGION"])== "SL")
	 {
	 header("Location: aocs_nl-pg.php");
	 }
	 if(isset($_GET["GET_VALUE_REGION"])== "VI")
		 {
		 header("Location: aocs_nl-pg.php");
		 }
		 if(isset($_GET["GET_VALUE_REGION"])=="NM")
		 {
		 header("Location: aocs_nl-pg.php");
		 }
		 if(isset($_GET["GET_VALUE_REGION"])== "SM")
			 {
			 header("Location: aocs_nl-pg.php");
			 }
		 else
			 {
			 echo "error";
			 }


 }

?>

 

it is not work to jump another page.

 

 

Thanks

Edited by jayson_ph
Link to comment
Share on other sites

In addition to moving the header redirects to the top of the script, the if statements are being overloaded. For example, the following only tests if $_GET["GET_VALUE_REGION"] is set. It ignores the last part.

 

<?php
if(isset($_GET["GET_VALUE_REGION"])== "SL")
?>

 

The code could be rewritten as

 

<?php
if(isset($_GET["GET_VALUE_REGION"]) && $_GET["GET_VALUE_REGION"] == "SL")
?>

 

...but you've already tested the variable in the first if. The code could be streamlined to

 

<?php
if(isset($_GET["GET_VALUE_REGION"])) {
    if($_GET["GET_VALUE_REGION"]=="NCR") { header("Location: aocs_ncr.php"); exit(); }
    if($_GET["GET_VALUE_REGION"]=="NL") { header("Location: aocs_nl-pg.php"); exit(); }
    if($_GET["GET_VALUE_REGION"]=="SL") { header("Location: aocs_nl-pg.php"); exit(); }
    if($_GET["GET_VALUE_REGION"]=="VI") { header("Location: aocs_nl-pg.php"); exit(); }
    if($_GET["GET_VALUE_REGION"]=="NM") { header("Location: aocs_nl-pg.php"); exit(); }
    if($_GET["GET_VALUE_REGION"]=="SM") { header("Location: aocs_nl-pg.php"); exit(); }
    else {
         echo "error";
    }
}
?>

Link to comment
Share on other sites

Hi all.

 

i got problem? when i try your suggested code above, in my local pc using xampp it work good. but when i trying to publish the code to make it live, is dose not work any more. why? any help please..

 

here is the live ulr http://www.octagon.com.ph/aocs_ncr.php

 

Thanks you..

Edited by jayson_ph
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.