Jump to content

adding to GET after submit


severndigital

Recommended Posts

I am using the GET method to submit my form.

 

I would like to add to the resulting url items that were in the current url.

 

Is there a way to do it without adding all of the variables to hidden form fields?

 

example

 

GET Method produces this url

 

http://www.site.com/index.php?datein=GETresult&dateout=GETresult&Submit=Submit

 

I would like to add to the url for example...

 

http://www.site.com/index.php?datein=GETresult&dateout=GETresult&Submit=Submit&addeditem=addedvalue&addeditem=addedvalue

 

There can be anywhere from 5 to 12 variables in the current url.

 

 

while typing this i realize i might be able to produce hidden form fields by loading all the items into an array.

 

anyone have an easy way to do that??

 

Thanks,

C

Link to comment
https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/
Share on other sites

Those solutions only work if the form method is POST. I am using the GET method and it overrides anything in the action="" area of the form tag.

 

I have a working solution now using a for loop and the $_SERVER['QUERY_STRING'] command to dynamically produce hidden form fields.

 

looks like this

 

$string = explode("&",$_SERVER['QUERY_STRING']);
$items = array();
for($i = 0;$i < count($string); $i++){
          $vars = explode("=",$string[$i]);
          echo '<input type="hidden" name="' . $vars[0] . '" value="' . $vars[1] . '">';
}

 

I was hoping to just attach the string but this looks like the only way to do it using a GET method on the form.

 

Thanks

 

 

 

 

 

 

 

 

 

  • 2 weeks later...

apulmca2k4 can u kindly stop giving out ur email address so users bypass the forum and contact u directly.........

 

There are strict rules useing this forum...........

 

if u got a solution, then post it dont get users to contact u via ur email addresss....

 

the whole idear off this forum is to help others and showing others the solution..........

 

also if u want to charge users for using u, then add ur info to the freelance section

off this grate php forum.....

 

php freaks is not here for u to encourge users to use u as the only programmer please be warned........

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.