getColumns(); switch( $_GET['function'] ) { case "logout": setcookie("txtAcctNo", "", time()-3600, "/", ".diabeteshealth.com"); header("Location: " . $_SERVER['PHP_SELF']); exit(); break; case "subscribe": $acctType = "R"; if ($_COOKIE['txtAcctNo']) { setcookie("txtAcctNo", "", time()-3600, "/", ".diabeteshealth.com"); header("Location: " . $_SERVER['PHP_SELF'] . "?function=subscribe&acctType=" . $_GET['acctType']); exit(); } else if ($_GET['acctType'] == "C") { $acctType = "C"; } break; } switch( $_POST['function'] ) { case "subscribe": $acctType = $_POST['acctType']; break; } $getFunction = $_GET['function']; $postFunction = $_POST['function']; unset( $_POST['function'] ); if( $_COOKIE['txtAcctNo'] ) { $txtAcctNo = trim( $_COOKIE['txtAcctNo'], "DHdh" ); $loggedIn = true; } if( $_POST['txtAcctNo'] ) { $txtAcctNo = trim( $_POST['txtAcctNo'], "DHdh" ); } // retrieve account based on requests if( $txtAcctNo ) { $subscription = new Subscription($txtAcctNo, $mysqli); $subscriptionData = $subscription->getData(); $acctType = $subscriptionData['acctType']; } if( $loggedIn && $postFunction == "cancel" ) { $_POST['id'] = $txtAcctNo; // status = D is in the $_POST $subscription->setData($_POST); $subscription->save(); $subscriptionData = $subscription->getData(); $cancelled = true; } else if( $loggedIn && $postFunction == "subscribe" ) { $cannotSubscribe = "You have already subscribed. Your account number is DH" . $_COOKIE['txtAcctNo'] . "."; } else // function for when subscription data has been posted if( ( ( $postFunction == "update" || $postFunction == "renew" ) && $loggedIn ) || $postFunction == "subscribe" ) { $subscription = new Subscription($_POST['id'], $mysqli); $noBilling = $_POST['noBilling']; unset($_POST['noBilling']); $Charged = false; foreach($_POST as $key => $value ) { // for bill_* fields if (substr($key, 0, 4) == "bill") { // if billing should be same as shipping if ($noBilling) { $info = substr($key, 5); $_POST[$key] = $_POST['ship_' . $info]; } else { fieldIsBlank($key, $value); } } // for paid accounts else if( $acctType == "R" ) { // if payment is mailed or coupon, clear all credit card fields $paymentTypes = array ('mailed', 'coupon'); if( in_array($_POST['paymentType'], $paymentTypes) && substr($key, 0, 2) == "cc" ) { $_POST[$key] = ""; } elseif ($_POST['paymentType'] == 'coupon') { if ($key == 'Coupon') { $Coupon = Coupon::FindByRedeemableCode($_POST['Coupon']); if (empty($Coupon)) { $errors[$key] = true; } else { if ($Coupon->Used) { $errors[$key] = true; } else { $Charged = true; } } } else { fieldIsBlank( $key, $value ); } } else { if( $key == "ccnumber" ) { // check format of credit card number if( !is_numeric($value) || strlen($value) != 16 ) { if ($_SERVER['REMOTE_ADDR'] != '99.100.165.10') { $errors[$key] = true; } } } // if required field is blank else { fieldIsBlank( $key, $value ); } } } else { fieldIsBlank( $key, $value ); } /*if (is_array($value)) { print $key . " = " . print_r($value) . "
"; } else { print $key . " = " . $value . "
"; }*/ } // must be looped through after bill_* fields are changed foreach($_POST as $key => $value ) { // *state fields if( substr($key, 5) == "state" ) { // state length must be 2 if( strlen($value) > 2 ) { $errors[$key] = true; } } } if ($_SERVER['REMOTE_ADDR'] == '99.100.165.10') { /*echo '
'.print_r($errors, true).'
';
    echo '
'.print_r($_POST, true).'
';
    exit();*/
}
    
    if (empty($errors) && $_POST['paymentType'] == 'cc')
    {
   				if( $_POST['term'] == "12" )
   				{
   					$_POST['amountDue'] = "30.00";
   					$_POST['ratePerIssue'] = "5.00";
   				} 
   				else if ($_POST['term'] == "24")
   				{
   					$_POST['amountDue'] = "45.00";
   					$_POST['ratePerIssue'] = "3.75";
   				}
   				else if ($_POST['term'] == "36")
   				{
   					$_POST['amountDue'] = "60.00";
   					$_POST['ratePerIssue'] = "3.33";
   				}
                                $_POST['currentValue'] = $_POST['amountDue'];
                                $_POST['lastPaymentDate'] = date('Y-m-d');
        require_once $_SERVER['DOCUMENT_ROOT'].'/includes/anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
        // If it's us, it's a test
        if (isset($_GET['DEV']))
        {
            $transaction = new AuthorizeNetAIM('36g7d59FBs6N', '9w3Y47844YC7bdwQ');
            $transaction->setSandbox(true);
        }
        else
        {
            $transaction = new AuthorizeNetAIM('2yXJR6D7wJ2E', '534S389UnVn9C3w5');
            $transaction->setSandbox(false);
        }
        $transaction->amount = $_POST['amountDue'];
        $transaction->card_num = $_POST['ccnumber'];
        $transaction->exp_date = $_POST['ccexpmm'].'/'.$_POST['ccexpyy'];
        $transaction->card_code = $_POST['ccv'];
        
        $transaction->setCustomField('x_first_name', ($_POST['bill_fname']?$_POST['bill_fname']:$_POST['ship_fname']));
        $transaction->setCustomField('x_last_name', ($_POST['bill_lname']?$_POST['bill_lname']:$_POST['ship_lname']));
        $transaction->setCustomField('x_address', ($_POST['bill_address1']?$_POST['bill_address1']:$_POST['ship_address1']));
        $transaction->setCustomField('x_city', ($_POST['bill_city']?$_POST['bill_city']:$_POST['ship_city']));
        $transaction->setCustomField('x_state', ($_POST['bill_state']?$_POST['bill_state']:$_POST['ship_state']));
        $transaction->setCustomField('x_zip', ($_POST['bill_zipcode']?$_POST['bill_zipcode']:$_POST['ship_zipcode']));
        $transaction->setCustomField('x_email', ($_POST['bill_email']?$_POST['bill_email']:$_POST['ship_email']));
        $transaction->setCustomField('x_phone', ($_POST['bill_telephone']?$_POST['bill_telephone']:$_POST['ship_telephone']));
        
        $response = $transaction->authorizeAndCapture();
        //echo '
'.print_r($response, true).'
'; if (!$response->approved) { $errors['ccnumber'] = $response->error_message; } else { $Charged = true; } } // field checks out fine if( empty($errors) ) { foreach( $_POST as $key => $value ) { if( is_array($value) ) { // none value is removed, errors are done being checked $noneKey = array_search("none", $value); unset($value[$noneKey]); // turn arrays into CSVs $_POST[$key] = implode($value, ", "); } } if( $postFunction == "renew" || $postFunction == "subscribe" ) { if( $_POST['term'] == "12" ) { $_POST['amountDue'] = "30.00"; $_POST['ratePerIssue'] = "5.00"; } else if ($_POST['term'] == "24") { $_POST['amountDue'] = "45.00"; $_POST['ratePerIssue'] = "3.75"; } else if ($_POST['term'] == "36") { $_POST['amountDue'] = "60.00"; $_POST['ratePerIssue'] = "3.33"; } $_POST['netamt'] = $_POST['amountDue']; } if ($postFunction == "renew") { $subscription->renew($_POST['paymentType'], $_POST['amountDue'], $Charged, $_POST['term'], $issuesPerYear); unset($_POST['paymentType'], $_POST['amountDue'], $_POST['term'], $_POST['expireDate'], $_POST['currentValue'], $_POST['amountDue'], $_POST['promocode'], $_POST['updateDate'], $_POST['lastRenewalDate']); $subscription = new Subscription($_POST['id'], $mysqli); $subscriptionData = $subscription->getData(); $_POST['expireDate'] = $subscriptionData['expireDate']; $renewed = true; } else if ($postFunction == "subscribe") { if ($acctType == "R") { $_POST['promocode'] = "M5DHX"; $_POST['subscriptionType'] = $_POST['paymentType'] . "_" . $_POST['term'] . "_" . $_POST['amountDue']; $_POST['DP'] = "Y"; $_POST['currentValue'] = $_POST['amountDue']; $_POST['lastPaymentDate'] = date('Y-m-d'); } if ($acctType == "C") { $_POST['promocode'] = "QM6ZOWN"; $_POST['term'] = "24"; } $_POST['addDate'] = date("Y-m-d"); $_POST['expireDate'] = date("Y-m-d", strtotime( "+" . $_POST['term'] . " months")); $_POST['status'] = "I"; $_POST['qualType'] = "E"; if ($Charged) { $_POST['amountDue'] = 0; $_POST['status'] = 'A'; } $subscribed = true; } else { $updated = true; } $_POST['updateDate'] = date("Y-m-d");if (isset($_GET['DEV'])) { echo '
'.print_r($_POST, true).'
'; } $subscription->setData($_POST); $subscription->save(); $isConsumer = false; if ($_POST['acctType'] == 'R') { $isConsumer = true; } if ($postFunction == "subscribe") { sendSubscriptionEmail( "Diabetes Health", "subscribe@diabeteshealth.com", $_POST['ship_fname'], $_POST['ship_lname'], $_POST['ship_email'], $subscription->getId(), $isConsumer, $_POST['netamt'], $_POST['term'] ); } else if ($postFunction == "renew") { sendRenewalEmail( "Diabetes Health", "subscribe@diabeteshealth.com", $_POST['ship_fname'], $_POST['ship_lname'], $_POST['ship_email'], $subscription->getId(), $isConsumer, $_POST['netamt'], $_POST['term'] ); } if ($_POST['paymentType'] == 'coupon') { Coupon::SelectDB(); $Coupon->Used++; $Coupon->SubscriptionID = $subscription->getId(); $Coupon->SaveIt(); } // Send an email to Deb letting her know that someone signed up $To = 'Deb '; $Subject = 'New Signup!'; $Message = 'Account: '.$subscription->getId()."\r\n"; $Message .= 'Name: '.$_POST['ship_fname'].' '.$_POST['ship_lname']."\r\n"; $Message .= 'Company: '.$_POST['ship_companyname']; $Headers = 'From: Diabetes Health '."\r\n"; $headers = 'CC: Dev '; mail($To, $Subject, $Message, $Headers); } // When finished dealing with sub data, set data variable to what's been submitted by POST. // In case of errors, user can change their invalid data and try again. $subscriptionData = $_POST; } // if no errors, subscription data exists and: if (empty($errors) && $subscriptionData && ( // 1) login cookie exists and equals requested ID ($_COOKIE['txtAcctNo'] == $subscription->getId()) // or || // 2) logging in with correct ID and the sub's zip code equals requested zip ($postFunction == "login" && $subscription->getId() && substr($subscriptionData['ship_zipcode'], 0, 5) == substr($_POST['txtZip'], 0, 5)) // or || // 3) user is a new subscriber ($subscribed) )) { // log in and set login cookie $loggedIn = true; setcookie('txtAcctNo', $subscription->getId(), 0, "/", ".diabeteshealth.com"); } // begin building account editor if ($loggedIn || $getFunction == "subscribe" || $postFunction == "subscribe") { $fields1 = array('ship_fname', 'ship_lname', 'ship_title', 'ship_companyname', 'ship_address1', 'ship_address2', 'ship_city', 'ship_state', 'ship_zipcode', 'ship_country', 'ship_telephone', 'ship_email'); $fields2 = array('bill_fname', 'bill_lname', 'bill_title', 'bill_companyname', 'bill_address1', 'bill_address2', 'bill_city', 'bill_state', 'bill_zipcode', 'bill_country', 'bill_telephone', 'bill_email'); if ($loggedIn) { if ($getFunction == "renew") { if ($subscriptionData['status'] == "I") { $cannotSubscribe = "We're sorry, but you cannot currently renew because your account is pending activation."; } else if ($subscriptionData['ship_country'] != "USA" || $subscriptionData['bill_country'] != "USA") { $cannotSubscribe = "We're sorry, but we no longer offer international subscriptions."; } } $shipInfo = array(); $billInfo = array(); // try to create identical arrays foreach($fields1 as $field) { $shipInfo[substr($field, 5)] = $subscriptionData[$field]; } foreach($fields2 as $field) { $billInfo[substr($field, 5)] = $subscriptionData[$field]; } $infoDiff = array_diff_assoc( $shipInfo, $billInfo ); if (isRecursiveArrayEmpty($billInfo) || empty($infoDiff)) { $noBillInfo = true; } $subscriptionData['JTPre[]'] = explode(", ", $subscriptionData['JTPre']); $subscriptionData['magazineDistribution[]'] = explode(", ", $subscriptionData['magazineDistribution']); $subscriptionData['RP[]'] = explode(", ", $subscriptionData['RP']); } } function fieldIsBlank( $key, $value ) { if ($key == 'Coupon' || $key == 'ccv') { return ''; } global $subscriptionsColumns; global $errors; if ($subscriptionsColumns[$key]->isRequired()) { if ( // 0 is an okay value (!is_numeric($value) && empty($value)) || // none is the default value for radio buttons $value == "none" || // no fields with only spaces trim($value) == "") { $errors[$key] = true; } // none is the default checked value else if (is_array($value) && count($value) == 1 && $value[0] == "none") { $errors[$key . "[]"] = true; } } } function printFields( $fields, $noValue=FALSE ) { global $subscriptionData; global $subscriptionsColumns; global $geoData; global $getFunction; global $errors; ?>
style="color: red"> getName()))?> isRequired()) { ?> * DH getCodes(); ?> United States
/> Visa           /> MasterCard
CCV value="" size="25" />
style="color: red">

$value) { ?> checked="checked" />
= sizeof($answers)/2) { $counter = -1; ?>
style="color: red">

$value) { if ($column == "magazineDistribution" && $key == "07") { ?>
= sizeof($answers)/2) { $counter = -1; ?>

If "Other" selected, please specify:

Get Your Free Subscription to Diabetes Health Professional!

Stay Inspired by Subscribing to Diabetes Health!

Renew Subscription

Cancel Subscription

Account Information

Subscribed!

Welcome to Diabetes Health, !

For reference, your Account Number is DHgetId() ?>. This number will also be on your print mailing label with an expiration date.

We look forward to helping you to meet your health and lifestyle goals. Please feel free to contact us with any story ideas you would like us to include. Send an email to storyidea@diabeteshealth.com.

Are you sure you want to cancel your subscription to Diabetes Health? We do not rebill subscribers at the end of their cycle without their consent.

You have renewed your subscription.

Your subscription has been cancelled.

Your account has been updated.

There was an error with your form. Please double-check your entries.

'.print_r($errors, true).'
':''?>


Jun-Jul Aug-Sep Oct-Nov

Why does the WSJ call Diabetes Health the weapon against diabetes?

Former Chrysler Motors President Lee Iacocca’s quote best answers this question by saying; “ Diabetes Health magazine provides the best, most unbiased information to the diabetes community. I highly recommend it.'"

Nadia Al-Samarrie
Nadia Al-Samarrie
What makes Diabetes Health different from any other publication out there?

Diabetes Health magazine is a lifestyle publication for those living with diabetes or the people who care for them. The newly diagnosed and the experienced will be delighted and impressed by the articles written by people living with type 1 and type 2 diabetes. Other contributors include family member that care for those with diabetes.

In fact, our Founder and Publisher, Nadia Al-Samarrie was not only born into a family with diabetes, but also married into one.

She was propelled at a young age into “caretaker mode,” and with her knowledge of the scarcity of resources, support, and understanding for people with diabetes, co-founded Diabetes Interview–now Diabetes Health magazine.

Stay Motivated

As you already know, diabetes can be a burn out disease. Staying motivates takes effort, unless you are reading Diabetes Health magazine.

Subscribe Now!

Starting with your first issue you can expect to:

~ Get inspired by our everyday heroes and celebrities living with diabetes
~ Get a new perspective on living with type 1 and type 2 diabetes
~ Know what’s the latest in medical devices, medication options and products
~ Stay on top of the latest research on diabetes
~ Try making one of our yummy recipes
~ Giggle reading one of our cartoons and
~ Test your knowledge on diabetes in one of our crossword puzzles.

Don’t wait any longer. Get started today by treating yourself or anther person with diabetes to a useful practical publication that is dedicated to make your life easier.

Please complete and pay for your subscription below.

The must-have resource for physicians, educators and medical professionals who focus on the treatment of diabetes.

Finally! A fresh take on the “professional” journal. Each bi-monthly issue cuts through the jargon and presents the most important information you need to enhance your practice and assist your patients.

Diabetes Health Professional is brought to you from the publishers of Diabetes Health magazine and applies the same unbiased approach we have used for nearly 15 years to expand the knowledge and expertise of medical practitioners and clinical educators like you.

Your Diabetes Health Professional subscription lasts for two years. At the end of your subscription, you will be contacted to renew.

checked="checked" /> This is a gift subscription

A red asterisk (*) means the field is required.

"Yes", "N"=>"No")); printRadioQuestion("Complimentary copies of Diabetes Health for your patients?", "complimentary", array(0=>0, 40=>40)); printRadioQuestion("What best describes the location where you work?", "BU", $proQuestions['BU']); printCheckboxQuestion("What are your credentials?", "JTPre", "JT_other", $proQuestions['JTPre']); printRadioQuestion("How many diabetes patients do you see per month?", "PN", $proQuestions['PN']); printCheckboxQuestion("What diabetes related products do you recommend?", "RP", "RP_other", $proQuestions['RP']); printCheckboxQuestion("How do you distribute the magazine?", "magazineDistribution", "magazineDistribution_other", $proQuestions['magazineDistribution']); printRadioQuestion("I would like to receive Diabetes Health subscriber cards to give to my patients.", "SC", $proQuestions['SC']); } ?>

Account Services

Please enter your account number and zip/postal code from the label on your issue. Your account number starts with DH and is followed by four to six numbers (e.g., DH123456). See the illustration below.

Sample DH Label

Account Number
ZIP/Postal Code