[Pro] Enquiry form for specific product

Hi, I would like to set up a process on a freeway website, whereby a user can view a product, click on an Enquire Now button and either:

  1. Open an email with the product name within the email subject.
    or
  2. Open a form with the product name pre-populated into one of the form fields.

Can this be be done?

Look forward to any feedback.


freewaytalk mailing list
email@hidden
Update your subscriptions at:

These are both possible, although I will warn you about the first one – the last time I used that trick to fill out an e-mail, my Mac gave me a sternly worded warning dialog before allowing me to open my mail app with the pre-filled message. It’s easy to do, but possibly going the way of the dinosaur on account of security and privacy concerns.

To create a mail message with a pre-filled subject line, all you need to do is create a link with this kind of URL:

mailto:someone(a)somewhere.dom?subject=Product+Name+Here

Notice the plus signs replacing the spaces. This is known as a URL-encoded string. A URL cannot contain spaces, and certain characters have special meaning and so need to be escaped if they are being used innocently (without that meaning intended).

Also (if you’re reading this in a mail application) I replaced the @ sign in the address with parentheses around an a. That was just for the benefit of the Web archive of this list. If I don’t do that, it would turn the address into “email (at) hidden”. So don’t do that, it’s not part of the scheme.

To get a link to fill in a form, you’re going to need to use a programming language like PHP on your form page. You won’t need PHP on the page that links to the form, just on the form page itself. The trick is to intercept a variable passed in the link and then write it into the form page while the page is loading.

The link would look like this:

http://example.com/form_page.php?product=Product+Name+Here

On the form page (which you would rename from .html to .php, as above) you would catch that “product” variable somewhere above the visible page like this:

<?php $product = $_GET['product'] || ""; ?>

Then, in the form element where you want $product to appear, you would make the value property of the text field read <?php echo urldecode($product); ?>. Now if someone comes to that form page without the ?product=whatever part in their URL, the field is blank, but if they have that value in the URL, whatever is in there will appear in the form field on the page, like magic.

Walter

On Aug 30, 2019, at 5:37 AM, Matt Covarr email@hidden wrote:

Hi, I would like to set up a process on a freeway website, whereby a user can view a product, click on an Enquire Now button and either:

  1. Open an email with the product name within the email subject.
    or
  2. Open a form with the product name pre-populated into one of the form fields.

Can this be be done?

Look forward to any feedback.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

To clarify the second example, you would put the first blob of PHP code into the Page / HTML Markup dialog, in the Before HTML section. You could simplify the second blob by making the first one do the url decode bit:

<?php $product = urldecode($_GET['product']) || ""; ?>

Then your text field’s value would simply be

<?php echo $product; ?>

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Hi Walter, Thanks so much for taking the time to explain this. I will give it a go and let you know if I have any glitches along the way.


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Hi Walter,

Hope you are able to clarify:

  1. Would each product require its own form page, or would one form page work?

  2. The code below…does this appear in the HTML markup dialog of the form page or the actual product page?

<?php $product = urldecode($_GET['product']) || ""; ?>
  1. The below piece of code them goes into your form’s text field value, where you want to the product name to pre populate the form.

Hope I am on the right track here?


freewaytalk mailing list
email@hidden
Update your subscriptions at:

One form for all products, because you are injecting the product name into the form as one of its variables.

Number 2 goes in the Before HEAD of the form page. The product page does not have to include any PHP for this to work – everything is in the form page. You just have to manually set the links on the individual product pages (from your Buy Now or More Info anchors) so that they include the ?product=Some+Encoded+Product part. Freeway can’t do that itself (there’s no way to modify an automatic link, which is what you get if you simply choose the page title from the popup “globe” menu at the bottom of the application frame). Instead, you use the Hyperlink dialog and the External tab to enter the actual filename of your form page, including the “querystring” part as above. So if your form page was named (file name, not the title that appears in the browser) get_info.php, you would enter `get_info.php?product=Some+Encoded+Product.

Number 3 goes into the Value field in Freeway’s form element inspector. Draw or insert the form element (a text field), and while that element is highlighted (corner handles showing) look at the Inspector. In the third tab from the left (Output) there are two fields at the top: Name and Value. Set the Name to whatever you like (I’d call it product_name). Set the Value to the PHP code <?php echo $product; ?>. That code will appear on screen inside the text field, but as long as the page itself has a .php file extension, when the Web server displays it, it will be entirely replaced, either by nothing, or by the value of $product as set by the previous code in the Before HEAD.

One last thing that might trip you up (but only if you use folders to organize your pages within the site) is relative linking to traverse a nested site structure. Lets say you have organized your product pages in a products folder. You may do this to keep the left column of the Freeway interface easy to navigate in a large site, say. If your more info form is in the products folder, then nothing about what I wrote above changes – you would simply make your External URL start with the bare file name more_info.php or whatever you’ve named it. But if you are using your your.site/contact/contact_us.php form instead, the link above would change to be ../contact/contact_us.php?product=Some+Encoded+Product. The two leading dots mean “navigate up one directory level”, which gets you out of the products directory into its parent directory, which is the parent of both contact and products. You’re not limited in the number of such traversals, either. You may need to go way up a tree, depending on how you’ve organized your site with sub-directories. ../../../some/other/folder/file.php is not unheard of. But if everything is in one folder, then you won’t need to worry about this at all.

Walter

On Sep 2, 2019, at 8:38 AM, Matt Covarr email@hidden wrote:

Hi Walter,

Hope you are able to clarify:

  1. Would each product require its own form page, or would one form page work?

  2. The code below…does this appear in the HTML markup dialog of the form page or the actual product page?

<?php $product = urldecode($_GET['product']) || ""; ?>
  1. The below piece of code them goes into your form’s text field value, where you want to the product name to pre populate the form.

Hope I am on the right track here?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Hi Walter,

I have now set this all up, I must be about 90% there…my only issue now, is that I all can get to appear in the variable form filed, is : 1

Here is ther url to the product page which is set up as you’ve outlined:Renée Krige Leger - Underwater
If you click on the ENQUIRE button below the product, you are taken to the form, where you will see the “1” in the subject field.

Any ideas where I would have gone wrong here?


freewaytalk mailing list
email@hidden
Update your subscriptions at:

1 in PHP sometimes means you have gotten something to equal “true”. There’s a couple of things I am seeing here. First, no matter what I replace the value of product with, I get 1. Only if I have nothing does it appear to be blank. That tells me that the part of the code that works is the || "" (OR empty string). So let’s step through the rest of the parts of this page. In the head or before head section, replace whatever you have with:

<?php 
$product = "";
if(isset($_GET['product'])){
  $product = urldecode($_GET['product']);
}
?>

That’s a very long-hand way of getting the same thing as my shorthand one-liner. It starts by setting the default to an empty string, then checks if there is anything in the querystring named product, then re-sets $product to whatever that is if present.

Try that part first. See what happens. If that gets you to the end, then great! If not, then let me know and we’ll look at the other part.

Walter

On Sep 3, 2019, at 10:21 PM, Matt Covarr email@hidden wrote:

Hi Walter,

I have now set this all up, I must be about 90% there…my only issue now, is that I all can get to appear in the variable form filed, is : 1

Here is ther url to the product page which is set up as you’ve outlined:Renée Krige Leger - Underwater
If you click on the ENQUIRE button below the product, you are taken to the form, where you will see the “1” in the subject field.

Any ideas where I would have gone wrong here?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options