HTML form data is not submitted for PHP

I want to pass information from an HTML form to a PHP page. My problem is that the data from the form is not accepted. What am I doing wrong?

HTML FORMAT

<div id="go">
    <form method="get" action="client_authorized.php">
        <fieldset>
            <input type="text" name="query" class="input-text" />
            <input type="submit" value="Secure Client Access" class="input-submit" />
        </fieldset>
    </form>
</div>

client_authorized.php

<?php
     print $_GET['query'];
?>
+3
source share
2 answers
<div id="go">
    <!-- see the moved `target` attribute from other form element to here -->
    <form target="_blank" method="get" action="client_authorized.php">
        <fieldset>
            <input type="text" name="query" class="input-text" />
            <!-- <form target="_blank"> -->
            <input type="submit" value="Secure Client Access" class="input-submit" />
            <!-- </form> -->
            <!-- this form here is as useless as these comments are, define target in main form -->
        </fieldset>
    </form>
</div>

Basically, your second one <form/>overrides the first <form/>elements, so it loses data when publishing.

Oh, by the way, PHP print();will not output your array data (at least I think so). You should use print_r();or instead var_dump();.

+4
source

The submit button is completed in another <form>. It should be <input type='submit'>. Just remove the excess <form></form>.

<div id="go">
  <form method="get" action="client_authorized.php">
    <fieldset>
        <input type="text" name="query" class="input-text" />
        <input type="submit" value="Secure Client Access" class="input-submit" />
    </fieldset>
  </form>
</div>
+5
source

All Articles