Focal55 wants to be your web guy

Vertical Response Tutorial: Auto Submit Contact Information

July
11

By Joe Ybarra, Lead Developer

LOS ANGELES, Calif. — Need mailing list collection?

The following tutorial will show you how to integrate your existing form with vertical response so that you can auto post contact information into your mailing list. We hate asking users to fill out multiple forms and when we are lucky enough to get a complete form filled out we maximize it. With some good old PHP cURL magic we can accomplish this easily. This tutorial assumes you are working with PHP and that cURL works on your server. It also assumes you already have a form and it posts to a PHP script.

Start by logging into your vertical response account and under the list drop down menu, choose Optin Forms. We need to create an Optin Form so that vertical response gives use a Form ID to use. Follow vertical response's tool to create a Optin Form. This includes the Name It, Design It, Pop Up or Redirect, Customize Your Opt-in Email, List and Alerts and Publish steps. During the Design Your Form step make sure to require First Name, Last Name and E-mail fields but uncheck Use CAPTCHA Verification. You should have sufficient security and validation methods applied to your original form. Once you get to the publish stage you will see the form HTML code that vertical response has generated for you. Check out the form action. It points to the location of our new Optin form. It should look like http://oi.vresp.com?fid=1234. Now you got a place to post your vertical response cURL integration script.

Find the optimal spot in your PHP e-mail to insert our cURL script that integrates with vertical response. Find the PHP mail() function being used in your PHP form processing. Once it is located, the cURL snippet should go right before that. Make sure that you have collected the user's first name, last name and e-mail address from the form so that you have it give to vertical response. Here is the snippet.

<?php
/*****************************
* Collect your form field submissions
*****************************/
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$useremail = $_POST['email_address'];

/*******************
* Post Values to Vertical Response
***********************************/
//FID is the form id that I got from VR's admin website
$url = "http://oi.vresp.com?fid=foobar";
//use this var to store the data in the typical GET format
$postFields = "first_name=".$fname;
$postFields .= "&last_name=".$lname;
$postFields .= "&email_address=".$useremail;

//Start the cURL stuff
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
//If cURL is successfull
if ($response = curl_exec($ch)) {
   
//You can do something here if you need
//ELSE email site admin that there was an error
}else{
   
//I like to know if cURL didn't work, so I will send an email to myself
        //SET WHO SHOULD RECEIVE THIS ERROR EMAIL
   
$site_admin_email = 'contact@yourdomain.com';
   
$error_msg = 'Hello, there was an error posting a contact to Vertical Response. Here is the information that should have been added:'. "<br>";
   
$error_msg .= 'First Name: '.$fname. "<br>";
   
$error_msg .= 'Last Name: '.$lname. "<br>";
   
$error_msg .= 'Email Address: '.$usermail. "<br>";
   
mail($site_admin_email,"There was an error posting to Vertical Response",$error_msg,$headers);
}
//CLOSE cURL
curl_close($ch);
/*******************
* End POST TO VERTICAL RESPONSE
***********************************/
?>

That should get the information to Vertical Response. If you need help feel free to contact us to speak with a representative.

Add a Comment