This is my code segment...

if (isset($POST['remove']));
{
$submitted = $
POST['remove']; <---Problem on initial load
if ($submitted == "click")
echo "You got it!";
}

echo "<br><br><br>For More Options Choose Below!<br><br>";

echo
'<form method="POST" action="reviewhits.php">
<input type="submit" name="remove" value="click"></input>
</form>
';

Please help... On the initial load of my page, it gives me "Notice: Undefined index: remove" when I submit this form, everything works great. Please advise!

    Two things ... <input> tags can't be closed, ie., there's no </input> tag.

    Secondly, it's a submit button - they're different than the other types: the value attribute becomes the text on the button, not the value of button's name. Try using a hidden field to pass "remove=yes" (or whatever you want). Another option would be to send it to a script that already knows what to do when it gets called.

      Steady.... Thanks for helping me clean up the code a little...

      I still have a problem with the remove as a hidden input entry.

      $submitted = $_POST['remove']; <---Problem on initial load

      with the new code added...
      <input type="hidden" name="remove" value="yes">

      on the initial load it throws up that error, and then after I click submit, it works just fine...

        Kinda funny. This thread http://www.phpbuilder.com/board/showthread.php?s=&threadid=10251574 talked about giving silly answers to questions. I guess steadyguy decided to follow it.

        Anyways, your code should be:

        if (isset($_POST['remove']))
        {
          $submitted = $_POST['remove']; 
          ...
        }
        

        The ) ; you had at the end of your isset line was finishing the statement so the $submitted line was always executing.

        And yes your can use </input>. In fact, xhtml requires all elements to have a closing tag though since input's don't have content then it's usually written as:
        <input type="hidden" name="whatever" value="1" />

          It's the semicolon after the opening of your if statement:

          if (isset($_POST['remove']));
          { ...

          should be:

          if (isset($_POST['remove'])) { ...

            Of course, you can use </input> but it won't validate ... and XHTML requires that all tags be closed, not that all tags must have closing tags - hence the ... /> notation. Subtle but important difference, I think.

              I am knew to the PHP world and it is still a little confusing. I can't find a good and reliable source for information. (or consistant anyways). That did the trick for me, I used one to many ;

              Hope you guys are around next time I need your help!

                Write a Reply...