How rude - I wasn't notified by email for these last two notes.

Anyway. Here's a modification I just coded while you were waiting (untested - so make a backup of the file first).

On that same file,

find:


$id1 = create_coupon_code($mail->fields['customers_email_address']);
$insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
(coupon_code, coupon_type, coupon_amount, date_created)
values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

$insert_id = $db->Insert_ID();

$db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $mail->fields['customers_email_address'] . "', now() )");
replace with:

Code:
$id1 = create_coupon_code($mail->fields['customers_email_address']);
      $insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
                                    (coupon_code, coupon_type, coupon_amount, date_created)
                                    values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

      $insert_id = $db->Insert_ID();

      $mail_from = $db->Execute("select admin_name FROM ".TABLE_ADMIN." where admin_id = '".(int)$_SESSION['admin_id']."'");

      while (!$mail_from->EOF) {
      $sent_from = trim($mail_from->fields['admin_name']);

      $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                    values ('" . $insert_id ."', '0', '".$sent_from."',
                            '" . $mail->fields['customers_email_address'] . "', now() )");
      }
Then, a couple of lines below,

find:


$insert_query = $db->Execute("insert into " . TABLE_COUPONS . "
(coupon_code, coupon_type, coupon_amount, date_created)
values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())");

$insert_id = $db->Insert_id();

$insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
(coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
values ('" . $insert_id ."', '0', 'Admin',
'" . $_POST['email_to'] . "', now() )");

}
replace with:

Code:
$mail_from = $db->Execute("select admin_name FROM ".TABLE_ADMIN." where admin_id = '".(int)$_SESSION['admin_id']."'");

      while (!$mail_from->EOF) {
      $sent_from = trim($mail_from->fields['admin_name']);

      $insert_query = $db->Execute("insert into " . TABLE_COUPON_EMAIL_TRACK . "
                                    (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent)
                                    values ('" . $insert_id ."', '0', '".$sent_from."',
                                            '" . $_POST['email_to'] . "', now() )");
      }

    }
Recall: Make a backup of the file, first, before you proceed.