Darkmatter5 Posted July 29, 2008 Share Posted July 29, 2008 If the URL to the page is http://www.hi.com/editjob.php?job_id=1 and there's a drop down list on the page named 'job' with a submit button named 'load' . When this code is run <?php if(!isset($_POST['load']) && !isset($_GET['job_id'])) { $byrndb->job_list(2,$job); } elseif(isset($_POST['load'])) { $job=$_POST['job']; $byrndb->job_list(2,$job); } elseif(isset($_GET['job_id'])) { $job=$_GET['job_id']; $byrndb->job_list(2,$job); } ?> why does the $_GET['job_id'] seem to take precedence over $_POST['job']? If $_POST['job'] is checked before $_GET['job_id'], shouldn't $job be set to $_POST['job']'s value over $_GET['job_id']. Quote Link to comment https://forums.phpfreaks.com/topic/117224-help-me-understand-why-one-item-takes-precedence-over-the-other/ Share on other sites More sharing options...
ignace Posted July 29, 2008 Share Posted July 29, 2008 <?php // create an .htaccess file that reads the line: // php_flag register_globals off if(!isset($_POST['load']) && !isset($_GET['job_id'])) { $byrndb->job_list(2,$job); // NOTICE: $job is undefined here } elseif(isset($_POST['load'])) { $job=$_POST['job']; $byrndb->job_list(2,$job); } elseif(isset($_GET['job_id'])) { $job=$_GET['job_id']; $byrndb->job_list(2,$job); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/117224-help-me-understand-why-one-item-takes-precedence-over-the-other/#findComment-603101 Share on other sites More sharing options...
genericnumber1 Posted July 29, 2008 Share Posted July 29, 2008 Can you post the form here so we can check your html? Quote Link to comment https://forums.phpfreaks.com/topic/117224-help-me-understand-why-one-item-takes-precedence-over-the-other/#findComment-603103 Share on other sites More sharing options...
Darkmatter5 Posted July 30, 2008 Author Share Posted July 30, 2008 $job isn't defined yet, so if a specific job isn't defined in job_id or by what is passed by the load button, then it's null and a generic list is generated with no specific job selected. Otherwise I'm wanting for what's selected in the dropdown to be most important, if something is in the dropdown AND in the URL as job_id then use the dropdown list selection over the URL variable. Here's the form code. <form method="post"> <input name='load' type='submit' value='Load record' /> </form Quote Link to comment https://forums.phpfreaks.com/topic/117224-help-me-understand-why-one-item-takes-precedence-over-the-other/#findComment-603558 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.