0

I have one variable already set (received through GET, too). I want to pass it, together with the variables of the form. The problem is that the new page takes only the variable from the from.
This is the code:

$insertion_type=$_GET['insertion_type'];
echo "<form action='index.php?insertion_type=".$insertion_type."&' method='get'>";
echo "Number of registrations<br /><input type='text' name='insertion_count'><br />";
echo "<input type='submit' value='Submit'>";
echo "</form>";

I am expecting to get this url after the submit:
index.php?insertion_type=somenumber&insertion_count=somenumber
but I get in place
index.php?insertion_count=somenumber

Please help. Thank you.

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Dexx
0

replace line 2

echo "<form action='index.php?insertion_type=".$insertion_type."&' method='get'>";

for this

echo "<form action=\"index.php?insertion_type=".$insertion_type."&\" method=\"get\">";
0

thank you. but I don't know why, it still works the same way, not passing insertion type after the subimt

1

I know this is an old thread but comes up on google, so here's the solution:

You can't have GET variables in both the action URL and in a form, so just move the action's get variables into the form using a hidden inputs. In this case replace second line with these two:

echo "<form action='index.php' method='get'>";
echo "<input type='hidden' name='insertion_type' value='" . $insertion_type . "'/>";

Edited by Dexx: n/a

Votes + Comments
one of the few necroposters to make a positive contribution
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.