isset($_GET['var']) not working

Im trying to modify a script from ChartDirector 3.1, the original script created a chart based on a year selected from a user, i wanted to mod this so it would compare two different countrys stats. The problem is when i hit the submit button from select.php the values of the two countrys is not picked up by graph.php. I think i've narrowed it down to the if else statments on graph.php , here--

if (isset($_GET['year'])){
      $SelectedYear = $_GET['year'];
}else{
      $SelectedYear = 2004;
}
if (isset($_GET['country1'])){
      $country1 = $_GET['country1'];
}else{
      $country1 = 'Australia';
}
if (isset($_GET['country2'])){
      $country2 = $_GET['country2'];
}else{
      $country2 = 'Brazil';
}
the first (and original if stat) works fine 'getting' the year selected, but the country1 and 2 vars are not getting set from the form on select.php and thus only comparing info on australia and brazil.
The address bar shows (example) ....select.php?year=1997&country1=Austria&country2=Argentina

echo $_GET["country1"];-- shows nothing on graph.php - but shows correct on select.php
echo $_GET["country2"];-- shows nothing on graph.php - but shows correct on select.php

can any one help.

thank you.
LVL 1
drnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

W33BCommented:
How are you submitting your vars to graph.php? sometime I've been tripped up in the past when using a POST method instead of a GET, the following could explain your problem:

<form action="graph.php?year=1975" method="POST">
  <input type="text" name="country1" value="Austria">
  <input type="text" name="country1" value="Argentina">
</form>

this will post and you can access both the $_GET["year"] (in action)
AND
$_POST["country1"], $_POST["country2"]

0
drnAuthor Commented:
select.php
-----------------------------------------
<html>
<body>
<form action="<?php echo $HTTP_SERVER_VARS["SCRIPT_NAME"] ?>" method="get">
      <select name="year">
            <option value="1997">1997
            <option value="1998">1998
            <option value="1999">1999
            <option value="2000">2000
            <option value="2001">2001
            <option value="1992">2002
            <option value="1993">2003
            <option value="1994">2004
      </select>
<select name="country1">
      <option value="Argentina">Argentina</option>
      <option value="Armenia; Republic of">Armenia; Republic of</option>
      <option value="Australia" selected>Australia</option>
      <option value="Austria">Austria</option>
      <option value="Azerbaijan; Republic of">Azerbaijan; Republic of</option>
      <option value="Belarus">Belarus</option>
      <option value="Belgium-Luxembourg">Belgium-Luxembourg</option>
      <option value="Belize">Belize</option>
      <option value="Brazil">Brazil</option>
      <option value="Bulgaria">Bulgaria</option>
</select>
VS
<select name="country2">
      <option value="Argentina">Argentina</option>
      <option value="Armenia; Republic of">Armenia; Republic of</option>
      <option value="Australia">Australia</option>
      <option value="Austria">Austria</option>
      <option value="Azerbaijan; Republic of">Azerbaijan; Republic of</option>
      <option value="Belarus">Belarus</option>
      <option value="Belgium-Luxembourg">Belgium-Luxembourg</option>
      <option value="Belize">Belize</option>
      <option value="Brazil" selected>Brazil</option>
      <option value="Bulgaria">Bulgaria</option>
</select>
  <input type="submit" value="submit">
</form>

<?php
if (isset($_GET['year'])){
      $SelectedYear = $_GET['year'];
}else{
      $SelectedYear = 2004;
}
if (isset($_GET['country1'])){
      $country1 = $_GET['country1'];
}else{
      $country1 = 'Australia';
}
if (isset($_GET['country2'])){
      $country2 = $_GET['country2'];
}else{
      $country2 = 'Brazil';
}
?>
<SCRIPT>
      //make sure the select box displays the current selected year.
      document.forms[0].year.selectedIndex = <?=$SelectedYear - 1990?>;
</SCRIPT>

<img src="graph.php?year=<?php echo $SelectedYear ?>">
</body>
</html>
0
W33BCommented:
I see where your problem is, you need to change your img src to:

<img src="graph.php?year=<?=($SelectedYear)?>&country1=<?=($country1)?>&country2=<?=($country2)?>">

and btw

<?=($var)?> is the quick way of doing <?php echo $var ?>

and

I don't know how relevant this is to you either but if I'm posting to the same page I set my action to  
<?=($_SERVER["PHP_SELF"])?>

W33B
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

rwestonCommented:
If you ever need to see what variables and values are being received, do a:

print_r($_POST);
or
print_r($_GET);
or just
print_r($_REQUEST);

Save yourself some lines of code (terinary operator):
<?
isset($_GET['year']) ? $SelectedYear = $_GET['year'] : $SelectedYear = 2004;
isset($_GET['country1']) ? $country1 = $_GET['country1'] : $country1 = 'Australia';
isset($_GET['country2']) ? $country2 = $_GET['country2'] : $country2 = 'Brazil';
?>

& like W33B Said, action to: <?=$_SERVER["PHP_SELF"]?> but it is == to ="<?=$HTTP_SERVER_VARS["SCRIPT_NAME"] ?>"
0
rwestonCommented:
oh eh:

do:

echo("<pre>");
print_r($_POST); // or any other array
echo("</pre>");  // to get a formatted printing of the arrays
0
drnAuthor Commented:
It's always something basic hat i miss, lol.
thanks w33b
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.