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

Link to comment
https://forums.phpfreaks.com/topic/274480-on-change-select/
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
https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412424
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..

Link to comment
https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412559
Share on other sites

Are you getting any errors? If so, what are they?

 

Have you tried turning on all errors?

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>

 

What does your current code look like?

 

Answering those questions may help us get to the bottom of the problem. :happy-04:

Link to comment
https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412610
Share on other sites

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.