Using a Third Party Script for Form Processing

Creating your Sparkle Forms

You create your forms in Sparkle in exactly the same way as you would if you were using Sparkle’s own in-built forms processor. Just add all the form fields to your page as normal. When the form is how you want it, you’ll add some additional fields that instruct your new form script how to deal with your form. These are called hidden fields and must be present in every form you create.  


The fields you will add will have specific variable names. In your main form, your fields will have variable names such as name, email-address and message. This is so you know what the information is when you receive the form contents in your email. 


Our special hidden fields will contain information that won’t be sent to you as part of the response - instead, they will be used to give additional information to the script which enable it to do its job correctly.


The fields you will add to your sparkle forms will have the following variable names:


        recipients

        good_url

        bad-url


The first field, recipients, will contain the alias name for the person to receive the response. If you remember, aliases were added to the script Therefore, when you add this field you will enter the appropriate alias name as the Initial Content of the field.  For example, if I wanted my form to go to the sales email address, I would set up the recipient form field in Sparkle like this:

The good_url field will be set up in exactly the same way but will contain the full URL of your success, or thank you page of your website. It should look something like this:

Finally, the bad_url field will contain the full URL of a page in your website to notify users if there was a problem with the form submission. Typically, it will be set up something like this:

Hiding the fields

Clearly, you don’t want these fields to be seen by your site visitors, and you certainly wouldn’t want them typing information into them. Therefore, you need to hide these fields from view. One of the best way of doing this is to overlay them - one on top of the other, and then group them. You can then place the group of fields onto your form and place a submit button on the top of them to obscure them from view. This is how the button would look on the canvas with the hidden fields all grouped behind the button:

Setting Up the form Submission Details

Now you have your form created, you have to tell Sparkle what to do with it. Select the submit button and choose Advanced Form Submission over in the style inspector. Check the boxes for ALL the fields on your form (including the hidden fields), and then set the URL of your script on your server. It will be in the format something like this:


https://yoursite.com/yourScriptFolder/yourScriptName.php

Time to Test

Whilst you will not be able to test your form in Sparkle’s preview, you can publish to a disk folder and test from there. If all goes well, you should get redirected to your thanks page after form submission. If that happens, check your email to ensure you receive the results. 


If you set up a bad_url page in your site, and you get directed there, it will mean the form submission failed. However, if that happens, you should still get an email from the system indicating that there was a problem.

Conclusion