Yohanne Posted February 14, 2013 Share Posted February 14, 2013 (edited) 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 February 14, 2013 by jayson_ph Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/ Share on other sites More sharing options...
gristoi Posted February 14, 2013 Share Posted February 14, 2013 you cannot have any output before using a header redirect. move your php part of the script to the top of the page Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412415 Share on other sites More sharing options...
cyberRobot Posted February 14, 2013 Share Posted February 14, 2013 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"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412424 Share on other sites More sharing options...
Yohanne Posted February 14, 2013 Author Share Posted February 14, 2013 Hi.. to cyberRobot and gristoi Thanks a lot for the reply.. and now i got it. thanks you. Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412433 Share on other sites More sharing options...
Yohanne Posted February 15, 2013 Author Share Posted February 15, 2013 (edited) 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 February 15, 2013 by jayson_ph Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412559 Share on other sites More sharing options...
cyberRobot Posted February 15, 2013 Share Posted February 15, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412610 Share on other sites More sharing options...
Barand Posted February 15, 2013 Share Posted February 15, 2013 Change the name of your submit button to , say, "btnSubmit", otherwise form.submit references that button Quote Link to comment https://forums.phpfreaks.com/topic/274480-on-change-select/#findComment-1412628 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.