Check form input against existing lead data for that user
Hi!
I have a page with content locked behind a login, and I need to cover a scenario where a user has signed up to access this page, but is not currently cookied as a known user. They'll be putting their email address into a form, which I'd like to compare against all leads in the database. If their email address is found in the database, I'd like to see if they are included in a specific list (which would have a yes or no value). If they are included in that list, they get access to the page content.
Here's the code I have currently - as you'll see, I'm having some trouble figuring out how to connect to the leads database.
I need to...
1. Grab their inputted value of the email field in the form
2. Look for that email address in the leads database
3. If they're found in the database, I need to grab all of their lead info based on their email address
4. I need to check the value of a specific piece of that lead info
You'll see some stuff about auth codes in here - we may change that in the future, but I believe the main roadblock I'm facing currently is grabbing this info from the database.
Thank you so much!!
<script>
MktoForms2.loadForm("[url]", "[instance]", 1195, function(form) {
form.onSuccess(function(vals, originalThankYouURL) {
var thankYouURL = "/insider-access/" + vals.authCode;
var newFollowUpURL = thankYouURL;
if ( **The lead data associated with this email address has a specific piece of access marked true** ) {
location.href = newFollowUpURL;
} else {
alert("Sorry we couldn't find your information, please sign up" );
}
return false;
});
});
</script>