pass data from a gallery page to a product
How you pass data depends on how you are getting to the next page. If a simple link is used, the browser sends a GET request. In this case the data is appended to the URL. The end of the file name and the start of the data is delimited by a question mark and each key/value data pair separated by an ampersand. Thus the URL would end up something like this:
The requested page then can receive the values with
If you are getting to the next page due to submitting a form, one typically sends a POST request, though GET is possible. To send data in addition to the data entered by the user, add hidden input fields to the form that contain your data values.
The action page then receives the data from
$_POST['input_field_name']where ‘input_field_name’ is actually the name attribute assigned to the form input field.
Another way to pass data is to have the page set a cookie value. Such values are automatically sent to the server with each request, the requested page retrieves the values from the
Thank you bcworkz,
I think I understand what you described. I’m not sure if this is the right solution. Maybe I can explain further. The site is still under construction and not available to show.
We sell embroidered products. The customer fills in the information they want to see on a custom blanket. Then they need to select an embroidery. Right now the solution is to create a gallery of images of the embroidry designs with captions and the user remembers the image they want and puts it into a field on the nproduct page. I think this is a little clunky.
What would be ideal is to have the customer click on the image they wat and the image and/or the image caption appear in the product page to be included in the shopping cart.
Hope this calrifies my requirement.
You indicated skepticism that any of the three options I presented would work for you. I’m not sure what you were envisioning, but for all practical purposes, one of the three presented are the only ways available to send data from browser to server. The entire Internet that communicates via HTTP uses one of these methods, one of them will certainly meet your needs.
I’ll describe the GET method, it’s probably the easiest to implement and understand. It’s also the least private because the selection is visible in the URL and browser address bar, but we’re not really dealing with personal information here.
Each image is wrapped in an anchor/link tag. The href address has image information appended to it. It can be the image name, style number, ID number, whatever will work best for the destination page to do what it needs to do with the data. The HTML for one image could look something like this:
<a href="http://example.com/path/destination.php?style=script"><img src="images/script-style.jpg"></a>
When the image is clicked, a request is sent to destination.php. That page can determine which image was clicked because
$_GET['style']will contain the value
Sorry, I was not doubting your knowledge or expertise. I was hoping for a lead to a plug-in or something like that. I know it wasn’t clear in my post.
Yes, I do understand what you have said and I will endeavour to try and apply it.
Thank You bcworkz
No worries, I took no offense, I took it as disbelief of the situation, not what I was telling you. Now that I know you are looking for a plugin, I had it all wrong anyway.
Since I tend to custom code most things, I don’t know much about available plugins, so I’m not able to help you with that. Good luck in your search!
- The topic ‘pass data from a gallery page to a product’ is closed to new replies.