Submit POST and GET variables in one form

前端 未结 5 1334
终归单人心
终归单人心 2020-12-19 11:32

I\'m working on a query tool that displays data from a MySQL database. The user is presented with a form containing a few dozen dynamically-generated checkboxes so that they

相关标签:
5条回答
  • 2020-12-19 11:42
    <form action="page.php?id=15" method="POST">
    <input name="ref_code_cust" type="text" value="some data">
    <input name="send" type="submit" value="send">
    </form>
    

    or

    www.mywebsite/page.php?id=15

    <form action="page.php" method="POST">
    <input name="id" type="hidden" value="<?php echo htmlspecialchars($_GET['id'], ENT_QUOTES); ?>"> 
    <input name="email" type="text" value="some data">
    <input name="send" type="submit" value="send">
    </form>
    

    we need to see your code also to make it easier, especial this array thing

    0 讨论(0)
  • 2020-12-19 11:50

    You cannot do a post and a get in the same form you even said that in your question.

    You have to either:

    1. Have 2 forms
    2. Have one thing submit with a post via ajax and then submit the other form with a get
    0 讨论(0)
  • 2020-12-19 11:50

    Endophage:

    If it's a PHP array, just store it in a session.

    This worked great. Obviously, I'm showing my web development greenness here as I didn't really consider using a session.

    0 讨论(0)
  • 2020-12-19 12:02

    You can set GET vars by changing URL:

    <form action="foo.php?getvar=15" method="POST">
    <input name="postvar">
    </form>
    

    For dynamic GET vars I believe you need Javascript.

    0 讨论(0)
  • 2020-12-19 12:03

    GET parameters go in the action url, POST parameters in the form's inputs

    <form method="post" action="/somepage.php?get=parameters&are=here">
        <input type="text" name="postParameter" value="this value will be sent as POST">
        ... etc
    </form>
    
    0 讨论(0)
提交回复
热议问题