Last active
December 29, 2015 12:39
-
-
Save ksnider/7671972 to your computer and use it in GitHub Desktop.
Parse a Name field and add results to Infusionsoft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Connect to the Infusionsoft API | |
require("isdk.php"); | |
$app = new iSDK; | |
$app->cfgCon("connectionName"); | |
// Connect the required file from HumanNameParser | |
require_once('HumanNameParser/init.php'); | |
// Get the contact ID | |
//$name = 'John F. Kennedy'; | |
//$email = 'jfk@whitehourse.gov'; | |
$name = $_POST['FullName']; | |
$email = $_POST['Email']; | |
// Instantiate a new parser object | |
$parser = new HumanNameParser_Parser($name); | |
// Use the methods to get First, Middle and Last | |
// Available methods are getleadingInit(), getFirst(), getNicknames(), | |
// getMiddle(), getLast() and getSuffix() | |
$fname = $parser->getFirst(); | |
$mname = $parser->getMiddle(); | |
$lname = $parser->getLast(); | |
// Update contact record using AddWithDupCheck method | |
$data = array('FirstName' => $fname, | |
'MiddleName' => $mname, | |
'LastName' => $lname, | |
'Email' => $email); | |
$update = $app->addWithDupCheck($data, 'EmailAndName'); | |
echo $update; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<title>Web Form Test</title> | |
</head> | |
<body> | |
<!-- this tells the browser where and how to send the data from the form --> | |
<form action='parse-names.php' method='post' enctype="multipart/form-data"> | |
Name : <input type='text' name='FullName'><br /> | |
Email : <input type='text' name='Email' ><br /> | |
<input type='submit' value='Submit'> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment