tags:

views:

54

answers:

4

Hi, I have a form with the code below, which sends form option choice as "project" variable.

<form name="projects" method="get" action="\web\ttt.php?str=aaa" >

However, the output always looks this:

/ttt.php?Projects=3 //there is str=aaa missing which I defined in the form action.

How to let it pass this variable?

Thanks

+4  A: 

You should use an hidden input control to pass variables with a form.

<input type="hidden" name="myname" value="myvalue" />
Gamecat
And why this doesnt work?
Petr
It didn't work because you were using get instead of post.
tharkun
It works, but the result will be in the POST data, not the GET data.
tunnuz
I mean, in $_POST, not in $_GET.
tunnuz
+6  A: 

When using GET as method all query params in the action attribute are discarded and the items in the form are used instead, either change to POST instead of GET or add a hidden field with the name 'str' and value 'aaa' to achieve what your are trying to do.

ChrisR
A: 

Use the method="POST" and add:

<input type="hidden" id="str" name="str" value="aaa">

in your form. The str variable will then be part of your post array and can be retrieved with $_POST['str'].

tharkun
A: 
<form name="projects" method="get" action="\web\ttt.php">
    <input type="hidden" name="str" value="aaa" />
    // Other form stuff
</form>
Rob Lokhorst