开发者

HTML to PHP form data not submitting

开发者 https://www.devze.com 2023-03-12 07:15 出处:网络
I want to pass information from an HTML form to a PHP page. My problem is that the data from the form is not getting submitted. What am I doing wrong ?

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

HTML 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>

client_authorized.php

<?php
     print $_GET['query'];
?>


Your submit button is wrapped in another <form>. This should be an <input type='submit'> instead. Just remove the extra <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>


<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>

Basicly your second <form/> overrides first <form/> elements, therefore loses data when posted.

Oh, by the way PHP's print(); won't print out your array data (at least I think so..), you should use print_r(); or var_dump(); instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号