severndigital Posted September 22, 2008 Share Posted September 22, 2008 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 More sharing options...
F1Fan Posted September 22, 2008 Share Posted September 22, 2008 $_SERVER['QUERY_STRING'] will give you everything from the ? on. Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-647452 Share on other sites More sharing options...
nadeemshafi9 Posted September 22, 2008 Share Posted September 22, 2008 you could add it before you submit the form eg, using javascript if ur pulling stuff from the form, on submit form.action or php action="<? bbblblah ?>" Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-647666 Share on other sites More sharing options...
F1Fan Posted September 22, 2008 Share Posted September 22, 2008 Sorta. You can add ?var=whatever&anothervar=somethingelse... after the file name (like action.php) in the action string on the submitting page. List your code and what you want to pass so I can modify it to show you what I'm talking about. Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-647692 Share on other sites More sharing options...
severndigital Posted September 22, 2008 Author Share Posted September 22, 2008 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 Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-647768 Share on other sites More sharing options...
apulmca2k4 Posted October 4, 2008 Share Posted October 4, 2008 Hi, I can do it using GET Method. I will add your required variables with their values in query string after form submission. It is 15 min work only. Apul [email protected] Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-656919 Share on other sites More sharing options...
redarrow Posted October 4, 2008 Share Posted October 4, 2008 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........ Link to comment https://forums.phpfreaks.com/topic/125229-adding-to-get-after-submit/#findComment-656933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.