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:

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:
but I get in place

Please help. Thank you.

Recommended Answers

All 3 Replies

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\">";

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

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 . "'/>";
commented: one of the few necroposters to make a positive contribution +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.