I’m trying to figure out how I can include information from a previous webpage on a contact form, the site is running WordPress. Here is my scenario:
- I have an image gallery and a button on each image, below the image caption.
- This button links to a webpage with a contact form where a user fills in a few choices about the image.
- This form is then emailed to the website owner.
How can I include the image caption from step 1 in the contact form?
Add something like
?image=1
to the urls on the image. Then you can use$_GET['image']
on the next page to get the image ID.WordPress has
add_query_arg()
to help you with that.HTML / HTTP is stateless. In your case, use something like sessions, cookies or GET / POST variables. Sessions and cookies are quite easy to use, with session being by far more secure than cookies. More secure, but not completely secure. Sessions store variables on the server where as the cookies get stored in the client side.
Session
Cookies
You can also use get GET/POST variables. For example, you can store the image caption variable on page 1, append it to the appropriate URL and then retrieve it on page 2.