Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active August 13, 2019 21:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/adcb5f261164932be02f to your computer and use it in GitHub Desktop.
Save billerickson/adcb5f261164932be02f to your computer and use it in GitHub Desktop.
<?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