php - How can I remove checkbox key values from a query string? -
I have a checkbox in a form, I am posting to a php form processor. My form receives a request for the processor web service Does this service require each check box? Services = chin & amp; Services = Neck and Services = Back and Location = 5
There is no key value, but with my php code, this is an [[outputting] [] after each service. $ Buildname = ' 'Lastname' = & gt; $ last name, 'email' = & gt; $ email, 'emailconfirm' = & gt; $ email, 'phone' = & gt; $ telephone, 'comments' = & gt; $ message ); $ Url = "Fakevadress?" . Send email ($ formok) {$ curl_handle = curl_init ($ url); Curl_setopt ($ curl_handle, CURLOPT_RETURNTRANSFER, true); Http_build_query ($ field, '', '& amp;'); // if everything is okay; $ Results = curl_handle; curl_close ($ curl_handle);}
My HTML box looks like this
Input type = " Checkbox "name =" services [] "value =" leg "/> input type =" Checkbox "name =" services [] "value =" neck "/> & input; input type =" checkbox "name = "Services []" value = "back" /> How can I fix this to get the output I need?
Services are an array, so you are receiving [] after each one if it does not , Then the last service in GET will replace all others. The way you want to do this will not work because every In the provision of services Is not there a loop for all the values of inquiry into your web service just by the media?
See for more information.
Edit : Whatever you want (not sure how this works, but this is what you want).
$ url = str_replace ('Services []', 'Services', $ url); do this
// build query string $ fields = array ('services' = & gt; $ services, 'location' = & gt; $ Location, $ Firstname, 'lastname' = & gt; $ last name, 'email' = & gt; $ email, 'emailconfirm' = & gt; $ email, 'phone' = & gt; $ telephone, 'comments '= & Gt; $ message); $ Url = "Fakevadress?" . Http_build_query ($ fields, '', '& amp;'); $ Url = str_replace ('Services []', 'Services', $ url); // Use it if [] $ url = str_replace (' Services % 5B% 5D ',' Services', $ url) is encoded;
Comments
Post a Comment