Carbos
Carbos

Reputation: 117

Double Get Send Data

In this page : page.php?id=value

I've this html's code:

<form action="" method="get">
<input type="text" name="key" />
<input type="submit" name="send />
</form>

It's redirect me to: page.php?key=value , i want to redirect to: page.php?id=value&key=value , how i can do it? I must redirect it to this page with PHP ?

Upvotes: 0

Views: 668

Answers (4)

Javad
Javad

Reputation: 4397

You can have the id as a hidden input in your form

<form action="" method="get">
   <input type="hidden" value="<?php echo $my_id; /*Suppose this variable contain your value */  ?>" name="id" />
   <input type="text" name="key" />
   <input type="submit" name="send" />
</form>

Upvotes: 1

Bhavesh G
Bhavesh G

Reputation: 3028

simply,

<form action="page.php" method="get">
    <input type="hidden" name="id" value="<?php echo $value ?>">
    <input type="text" name="key" />
    <input type="submit" name="send" />
</form>

Upvotes: 2

BReal14
BReal14

Reputation: 1584

put everything you want on the next page in your form:

<form action="page.php" method="get">
 <input type="text" name="id" value="<?php echo $_REQUEST['id'];?>" />
 <input type="text" name="key" />
 <input type="submit" name="send />
</form>

Really though, you should be using POST to send data, and the above code is NOT secure (allows anything in a url to easily end up in a form that could create some sql injection or XSS type issues.

Upvotes: 0

Spencer May
Spencer May

Reputation: 4505

You need to have the form's action set to the page you want it to submit to. If it is blank it will just submit to the same page.

<form action="page.php?id=value&key=value" method="get">
<input type="text" name="key" />
<input type="submit" name="send />
</form>

Upvotes: 0

Related Questions