I have a form using GET method. This form might have large amount of fields to update. so sometimes the URL gets too long. so I thought I can add more buttons to update each group of fields seperatedly.
The problem, even if I add a new button, it sends all FORMs parameters. How can I send only some of the parameters?
Edit: I cannot replace the GET to POST because this page is called not just from itself but also from other pages, so two of the parameters must be used as GET. I tried
if(isset($_GET['param_id1'])) {
$param_id1 = $_GET['param_id1'];
} else if(isset($_POST['param_id1'])){
$param_id1 = $_POST['param_id1'];
}
and within the form –
printf ("<form method='post' action='update_order.php'>"); // Use POST instead of GET
printf (" <input type='hidden' name='param_id1' value='$param_id1'>");
but it also did not work.
Edit 2: It did not work because I forgot to also change the URL –
<form method='post' action='update_order_test_post.php'>
My Form: [I Use PHP]
<form method='get' action='update_me.php'>
. . .
<input type='submit' name='Submit' value='Update All'> <!-- Original button -->
. . .
<input type='submit' name='Submit' value='Update One Line'> <!-- New button -->
Original URL: Seperated with newLines for clearence
http://mySite.com/update_order.php?
&infoA=aaa
&infoB=bbb
&infoC=ccc
&Submit=Update
¶m1[1]=11
¶m2[1]=21
¶m3[1]=31
¶m4[1]=41
. . .
¶m1[2]=211
¶m2[2]=221
¶m3[2]=231
¶m4[2]=241
. . .
¶m1[3]=3311
¶m2[3]=3321
¶m3[3]=3331
¶m4[3]=3341
. . .
¶m1[4]=411
¶m2[4]=421
¶m3[4]=431
¶m4[4]=441
. . .
. . .
I want to send only the following fields to the new URL, e.g. if the button in line 3 was clicked:
http://mySite.com/update_order.php?
&infoA=aaa
&infoB=bbb
&infoC=ccc
&Submit=UpdateOneLine
¶m1[3]=3311
¶m2[3]=3321
¶m3[3]=3331
¶m4[3]=3341
. . .
Thanks,
Atara.
Use POST, that’s what its for.
If you use POST then you don’t need to worry about reducing the number of items submitted. It may seem like it is a large number of items, but in terms of data you’re probably only dealing with a maximum of 10K of data being sent. The rest of your page is likely somewhere between 50 – 300K so its only a small part.
Just Change the form method to POST and use the parameters you need in your php receiving page.
UPDATE
To answer your specific question though, if you make each row a seperate form then it will only submit that row when the user clicks the submit button