Tip: Passing query string parameters to contact form page

Question:
Can I pre-fill in form fields from a URL query string?

Answer:
Yes, this feature was added in Version 2.9.7.1

What is a Query String? See query string at wikipedia

Here is an example, this is my contact form with a query string to pre-fill the name “My Test Name”:
http://www.fastsecurecontactform.com/contact?1name=My+Test+Name

Query String Rules:

  • Begin all queries after the URL with a question mark, do not repeat question marks without URL encoding them.
  • The query string is composed of a series of field-value pairs.
  • The field-value pairs are each separated by an equals sign.
  • The series of pairs is separated by the ampersand character &
  • Do not use the ampersand, question mark, or equals character in strings without URL encoding them
  • Spaces should be URL encoded as pluses.
  • Each field name must begin with the form number (the four standard available forms are numbered 1,2,3,4)
  • Field values must be url encoded to avoid problems.
  • For security reasons, the Attachment fields and CAPTCHA field cannot be filled in by URL query.
  • For security reasons, URL queries can only pre-fill the form, they cannot submit the form. This way security features like the CAPTCHA cannot be bypassed.
  • You do not have to fill all the fields with URL queries, you can just fill one or two if you want. The user can fill in the rest.
  • If using with extra fields, the extra fields must already be setup on the form edit page. For security reasons, you cannot dynamically add extra fields by query.

URL Encoding:

What us URL Encoding (percent encoding)? See article at wikipedia

Here is a site with a form to manually encode strings.
http://meyerweb.com/eric/tools/dencoder/

URL Encoding inside a PHP script:


<!--?php <br ?--> $query_string = 'foo=' . urlencode($foo) . '&amp;bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">click</a>';
?&gt;

Version 4.x changes:

Version 4.x introduces field tags for every field. There is a unique tag name for each form field. Tags are used for the form input names and for query input names. You can find the field tag on the form edit page.  To view a tag, click on the “Fields” tab, then click “Show Details” next to a field. There you will see the Tag, and for any fields you have added, you can change the tag if you like.

Available form fields to pass a URL query string to?

Standard Fields:
[form number]name=[string] (Name)
[form number]f_name=[string] (First Name)
[form number]mi_name=[string] (Middle Initial)
[form number]l_name=[string] (Last Name)
[form number]email=[string] (E-Mail Address)
[form number]mailto_id=[number] (use when the Email To: is a drop down list)
[form number]subject=[string] (Subject)
[form number]subject_id=[number] (use when the Subject: is a drop down list)
[form number]message=[string] (Message)

Example: Using a query for the Name field on form number 1:
?1name=Mike+Challis

Example: Using a query for the Name field and Email field on form number 2:
?2name=Mike+Challis&2email=name%40company.com

Extra fields with query input:

Types: text, textarea, date, password, hidden

Version 3.1.x and older:
[form number]ex_field[field number]=[string]
Example: form 4 using extra field 2 for text (phone number):
&4ex_field2=555-555-2125

Version 4.x and newer:
[form number]tag=[string]
Example: form 4 using extra field 2 for text (phone number):
&4tag=555-555-2125

Types: checkbox(single)

Version 3.1.x and older:
[form number]ex_field[field number]=1 (checked)
Example: form 1 using extra field 4 for checkbox(single)
(Join newsletter):
?&1ex_field4=1

Version 4.x and newer:
[form number]tag=1 (checked)
Example: form 1 using extra field 4 for checkbox(single)
(Join newsletter):
?&1tag=1

Types: checkbox(multiple), select-multiple

Version 3.1.x and older:
[form number]ex_field[field number]_[option number]=1 (checked)
Example: form 1 using extra field 5 for checkbox(multiple)
(Pizza Toppings: olives mushrooms cheese ham tomatoes)
?&1ex_field5_2=1&1ex_field5_3=1
(mushrooms option 2, and cheese option 3, selected)

Version 4.x and newer:
[form number]tag_[option number]=1 (checked)
Example: form 1 using extra field 5 for checkbox(multiple)
(Pizza Toppings: olives mushrooms cheese ham tomatoes)
?&1tag_2=1&1tag_3=1
(mushrooms option 2, and cheese option 3, selected)

Types: radio, select

Version 3.1.x and older:
[form number]ex_field[field number]=[option number] (checked)
Example: form 3 using extra field 7 for radio (select option 2, no)
(Do you like Onions? yes, no)
?&3ex_field7=2 (no) will be selected

Version 4.x and newer:
[form number]tag=[option number] (checked)
Example: form 3 using extra field 7 for radio (select option 2, no)
(Do you like Onions? yes, no)
?&3tag=2 (no) will be selected

Types: time

Version 3.1.x and older:
[form number]ex_field[field number]h=[number] (hour 01-12)
[form number]ex_field[field number]m=[number] (minute 00-59)
[form number]ex_field[field number]ap=[string] (AM or PM)
Example: form 1 using extra field 11 for time: 04:30PM
?&1ex_field11h=04&1ex_field11m=30&1ex_field11ap=PM

Version 4.x and newer:
[form number]tag_h=[number] (hour 01-12)
[form number]tag_m=[number] (minute 00-59)
[form number]tag_ap=[string] (AM or PM)
Example: form 1 using extra field 11 for time: 04:30PM
?&1tag_h=04&1tag_m=30&1tag_ap=PM

Multi-page forms limitation:
If you are trying to make a multi-page form out of this feature, the fields with options do not pass properly to form 2 because it expects option number as query input. The problem is: Form 1 sends out options as value strings, but form 2 only accepts input from query options as key numbers, not value strings.
This is a known limitation that remains to be resolved in possible future updates.

Reply

Do you need help?

Send us a Donation:

Donate to Mike Challis

Comments are closed.