Enter POST and GET variables in one form

I am working on a query tool that displays data from a MySQL database. The user is presented with a form containing several tens of dynamically generated flags so that they can choose how to view the data. This data is transmitted as a GET request and is displayed (explicitly) in the URL when the requested page loads.

On the same page as the input form, I have a php array that I generate dynamically, and it needs to be sent to the same place as the GET request. However, I do not want the values ​​in this array to display in the URL (I use them internally), so I would like to send them as a POST request.

Obviously, I cannot simultaneously execute a GET and POST request. I am new to web development (a guy in computer science, otherwise) and have been scratching my head about how to approach this.

Let me know if the problem is not clear.

EDIT: Many suggested adding them to the a la action variable:

form action = "process.php? get1 = value ...

All these inputs are generated dynamically, so they cannot be inserted into the action variable.

+5
source share
5 answers

Endophage:

If it is a PHP array, just save it in the session.

It did a great job. Obviously, I am showing my maturity of web development here, as I really did not consider using a session.

+1
source

GET URL- , POST

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

You cannot make a message and receive in the same form that you even said in your question.

You must either:

  • There are 2 forms
  • Ask one thing to send a message via ajax and then send another form using
+1
source

You can set get-vars by changing the url:

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

For dynamic GET vars, I believe you need Javascript.

0
source
<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 your code to also simplify, especially this array.

0
source

All Articles