This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 3
Email Verification
Started 10 years ago by timcov | 7 posts |
-
I need to ensure that users email addresses provided in the form are a valid email address before the completed form is finally submitted. I want to do this by having users click a verification link within an automated email sent to them. I understand Machforms doesn't include this functionality.
However the requirement seems very close to the save/resume functionality already provided. Would it be possible to devise a 2 page form that has it's second page (containing the submit button) hidden until the form has been saved and resumed?
Would a possible "hack" to do this be to include a hidden field that gets populated from the resume link and use the page logic to hide the last page until that field is populated with a parameter in the link?
Presumably I would need to alter the php so the emailed link also includes the hidden field as a parameter and adapt the "your progress has been saved" confirmation page so as not to display the link that would enable the user to continue without using the link in the email.
Is there a better way?
Posted 10 years ago # -
Interesting post as I just logged in to see if something like this already existed. I could use a double opt-in... for example, someone wants to join a mailing list and an email goes out asking them to verify/confirm the request.
Posted 10 years ago # -
Resolved!
Decided it wasn't sensible to mess with the save/resume function to achieve the email verification so instead checked out some php tutorials and other posts. I am not a programmer (I just copy with lots of trial and error!) so I'm sure Yuniar will wince at the poor "copy and paste" coding but it seems to work for me - and it only adds one line to the Machform code plus one new php file to receive the verification link!I need to use it for several forms (duplicated from the first so the critical email, verification key and status field element numbers stay the same) so it is still a work in progress but thought this may help those wanting something similar and welcome any improvement suggestions!
Steps:
1) Add two hidden number fields to the form - one to hold the verification key and one for a status to show if the email address has been "verified" or not. I've had to "hard code" those field names in the php so you need the element_ field names.
2) Set up an automatic email confirmation to user on the form with the email content of:
Click here to confirm and verify email
(where element_12 is the field for a random verification key and element_7 is the user email address)3) in the file /includes/post_functions.php find the lines:
//insert ip address and date created
$table_data['ip_address'] = $user_ip_address;
$table_data['date_created'] = date("Y-m-d H:i:s");
and below this add the line:
if($form_id == 12345){$table_data['element_12'] = RAND(); $table_data['element_13'] = "not verified";}(where 12345 is the form id, element_12 the field being used for the random verification key and element_13 for the verification status)
4) Create a new php file called email_verify.php in the machforms folder which includes the following (along with suitable headers,body etc for formatting)
<?php
/********************************************************************************
This process updates the verified field for user email addresses
********************************************************************************/
require('includes/init.php');
require('config.php');
require('includes/db-core.php');
require('includes/view-functions.php');$dbh = mf_connect_db();
$email = $_GET['email'];
$key = $_GET['key'];
if (isset($email) && isset($key)) {//validate the email address and key
$query = "select count(element_7) match_total from ".MF_TABLE_PREFIX."form_12345 WHERE element_12 = ? AND element_7= ?";
$params = array($key,$email);
$sth = mf_do_query($query,$params,$dbh);
$row = mf_do_fetch_result($sth);
$total_matches = $row['match_total'];
//check there is a single matched record
if($total_matches == 1)
{
//update the verified field (which is element_13)
$query = "UPDATE ".MF_TABLE_PREFIX."form_12345 SET element_13= ? WHERE element_12 = ? AND element_7= ?";
$params = array("verified",$key,$email);
mf_do_query($query,$params,$dbh);
//show the result
echo '<h4>Thank you for verifying.</h4>';
}
else {echo '<h4>Error - the email and/or key does not match our records</h4>';}
}
else {echo '<h4>Error - email and key parameters are required in the URL</h4>';}
?>Posted 10 years ago # -
Nice timcov. Yuniar, before I start hacking code, is this something that is on the drawing board for implementation? Double opt-in verification is becoming more important...
Posted 10 years ago # -
jblackburn. I agree - I'm surprised this hasn't been requested more often and how simple it seems to be to implement. Double opt-in is a standard requirement for newsletter signups and there are many other applications that need the user to confirm they own the email address provided and that it is a valid one.
I now notice that I said in 1) above to add two hidden number fields but then in 3) and 4) set the value to of the verification status field as "not verified" and "verified" so in my example that field type needs to be text. (using a check box would be better but text is easier for me!).
I need to use this for lots of forms so I've now set up a new form as a master template with the email, verification key and verification status fields the first ones added. I duplicate that for each new form I want to create meaning that those are now always conveniently column names: element_1, element_2 and element_3 and the code can work for more than one form.
I've also then used a common form tag of 'verify' on all of them so the program can identify which forms to apply the email verification process to without having to edit the code each time a new form is created. Therefore the line starting if($form_id == 12345)" in 3) above becomes:
if (stripos($form_tags, 'verify'){$table_data['element_12'] = RAND(); $table_data['element_13'] = "not verified";}
but it is also then necessary to add:
form_tags,
and
$form_tags = $row['form_tags'];
to the "//get form properties data" section starting about row 1549 as the form_tags value isn't being retrieved in the original code with the rest of the form property data.Hope this helps. I'm sure proper programmers would have better ways to do it but I found it surprisingly satisfying once I got it working myself!
Posted 10 years ago # -
timcov -- thank you for sharing this!
We don't have any plan to add double opt-in email verification into MachForm, since we would like to keep the core functionality of MachForm, which is building forms :-)
However, we do have another solution to overcome this.
Most people who build signup forms (along with the double opt-in function) most likely need to use it to build a mailing list.So, within the next update, we'll be providing a way for you to integrate your forms with mailing list system, such as MailChimp, Aweber, Constant Contact, etc.
I believe this is a better solution, since you'll have the full functionality to manage your mailing list (double opt-in, unsubscribe, etc).
MachForm Founder
Posted 10 years ago # -
yes that would be fantastic! I've been hoping for that integration as well. Do you think it would work with Campaign Monitor as well?
They have really fantastic features and stellar customer service like MF...
: ]Posted 10 years ago #
Reply
You must log in to post.