0

Edit: The issue ended up being because I was trying to resubmit to the same page. See Jeromes solution on here if you're experiencing the same issue.

if( isset( $_GET["fil"]) ){
    print "hi";
    $test = $_GET["fil"];
    print $test;
}
?>
<form action='prob1handlerFilter.php' method='GET'>
<h1>Filter These Results</h1>
  <select name='fil' id='fil'>
    <?php
    $SCORE = $_SESSION["players"]; 
    $uniqueDates = array_values(array_unique($_SESSION["players"]));
    sort($uniqueDates);
    $x = 0;
        while($x < count($uniqueDates))
        {
            print "<option value = '$uniqueDates[$x]'> $uniqueDates[$x]          </option>";
            $x = $x + 1;
        }
    ?>

Above is my code. The issue is that even though I can see in the URL string that fil is for sure set(http://127.0.0.1:8080/webserver1/prob1/prob1handlerFilter.php?fil=2012), it is telling me that it is undefined. If I change the if statement to !isset, it will go through and print "hi", but nothing else. This is just confusing me because I can literally see the variable in the URL string and all my other forms are working, just not this one....I'm at a complete loss as to why it's telling me that it's undefined. Full error is

Notice: Undefined index: fil in C:\xampp\htdocs\webserver1\prob1\prob1handler.php on line 70.

But clearly it isn't undefined because it's sitting up in the URL string...

5
  • Are you sending the form in the same page ? Commented Mar 2, 2018 at 0:42
  • @jerome I am, is that what's causing the issue? Commented Mar 2, 2018 at 0:47
  • I think so. Can you try changing the form action value to "<?php echo $_SERVER['PHP_SELF'];?>" Commented Mar 2, 2018 at 0:49
  • I think uniqueDates can be null or empty Commented Mar 2, 2018 at 0:51
  • @jerome That fixed it! Thank you so much! :) Commented Mar 2, 2018 at 0:51

1 Answer 1

1

Can you try changing the form action value to

 "<?php echo $_SERVER['PHP_SELF'];?>"
Sign up to request clarification or add additional context in comments.

1 Comment

This was it! Probably a common beginner mistake, but I'm still quite new to PHP. You saved me from probably hours of troubleshooting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.