We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Forms

Contact form via a href


I'm using Perch: 2.8.34. I'm creating a website for selling oldtimers. On the "cars" page, there is a list of oldtimers with some text, images and "contact us" button underneath each oldtimer. How do I code the "contact us" button with Perch, so my customer knows from which ad the information request comes? In html I would code this with ?SUBJECT in the href. Is this possible? Or is there another, better solution within Perch?

<div class="blog-item-foot">
<a class="btn btn-mod btn-round btn-small" href="mailto:info@mywebsite.be">Contact us<i class="fa fa-angle-right"></i></a></div> 

Thx Fre

Frederic Desauw

Frederic Desauw 0 points

  • 2 years ago

Frederic, I dont see why you wouldn't be able to append the query string as you have above, but this method really opens your "oldtimers" to spam since their email addresses will be visible in the html of the page. I am trying to think how Perch Forms could be used, but I am almost thinking a simple custom app which would handle the email part based on the ID of your clients.

Just wanted to chime in and say I think hard coding your clients emails is bad idea. There is already too much spam.


Even just a mini app in your page code with a couple of creative calls using perch_content_custom() would make this simple and much safer.

My last thought is you should be thinking about Perch Runway as it's built to handle larger amounts of data, where Perch Regions are more for static content (a lot of custom calls defeats the purpose of cashe content), collections are much more dynamic.

Hi Robert,

I'm a graphic designer and this is my second project with Perch. So a mini app sounds like rocket science for me. :) The test page is here: http://studiowolf.be/test/autolusso/autolusso-exclusive-cars.php

The first car is done with html. The second item (with the black images) is done with Perch.

If a customer is interested in the second car, he hits the contact button and fills in his email and brief message. My customer gets an email with subject: person A interested in car B. I'm looking for a solution with Perch for this project. It's the only page with Perch on the website. Perch runway is not an option.

For the images: is it possible to code the size? customer uploads images from 5MB: can I set the height 600px and maximum size of 500kb?

This is how I would do it in html:

<a href="mailto:me@example.be?Subject=Question%20about%20Alfa%20Romeo%20GTA%201984">Contact us</a>
Ben Furfie

Ben Furfie 3 points
Registered Developer

How comfortable are you with forms? There's a fairly simple solution involving wrapping the contact buttons in a form with a hidden field. That form then passes the value of that hidden field to the contact page where it is used as the value of another hidden field. When they get in touch, the value is then passed on through the email.

I know a bit off forms and my knowledge php is really really basic. Sounds a good idea/solution what you suggest! How can I apply this? Are there examples online? I don't want to make it too complex, because of my basic php knowledge.

Ben Furfie

Ben Furfie 3 points
Registered Developer

I haven't tested this, so it might not work out the box. But in theory, it's something like this.

This example assumes your page title is the same as the name of the thing they are looking at. You could easily swap it out for a <perch:content> tag with the name of the item. In the same way, the action can be swapped out too.

<form action="/contact.php" method="POST">
  <input type="hidden" name="service" value="<?php perch_pages_title(); ?>">
  <button class="button">Contact Us</button>

Then on your contact page template, you need to set up a variable for that hidden field to be assigned to:

<?php $service = $_POST['service']; ?>

You then just pass that value through as another hidden field within your form, whether you're using Perch Forms or a more standard solution.

Drew McLellan

Drew McLellan 2638 points
Perch Support

In your template:

<a href="mailto:<perch:content id="email" type="email" label="Email" required="true" escape="true" />?Subject=Question%20about%20<perch:content id="car_name" type="text" label="Car name" required="true" escape="true" urlencode="true" />">Contact us</a>