Jump to content

Recommended Posts

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'].

<?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);
}
?>

$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

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.