Instantly share code, notes, and snippets.

@billerickson /api.php Secret
Last active Feb 19, 2017

Embed
What would you like to do?
<?php
/**
* EA CRM.
*
* Basic API
*
* @package EA_CRM
* @since 1.0.0
* @copyright Copyright (c) 2014, Jared Atchison & Bill Erickson
* @license GPL-2.0+
*/
require_once( 'inc/init.php' );
// Check for API form submission
if ( isset( $_POST['secret'] ) && $_POST['secret'] == $settings['api_secret'] ) {
// Fields we are using
$fields = array(
'name' => '',
'email' => '',
'phone' => '',
'url' => '',
'date' => '',
'referral' => '',
'referral_other' => '',
'status' => '',
'budget' => '',
'timeframe' => '',
'inquiry' => '',
'services' => '',
);
foreach( $fields as $key => $value ) {
if( isset( $_POST[$key] ) && ! empty( $_POST[$key] ) )
$fields[$key] = $_POST[$key];
}
// Insert values into database
$add = $db->insert( 'entries', $fields );
$id = $db->insertId();
echo "New entry saved. Entry ID is $id";
} else {
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment