//declare includes
include ('../includes/global.inc');
include ('../includes/fddb.inc');
include ('../includes/fdfunc.inc');
include ('../includes/ccfunc.inc');
//include ('../includes/cctest.inc');
if ($_SERVER["SERVER_PORT"] != 443) {
header("Location: " .$fdsslurl . $_SERVER['PHP_SELF']);
exit;
}
if ($_POST['update']) { // form was submitted
$order_step = $_POST['order_step'];
$frm_flds = array($_POST['u_sal'],$_POST['u_fname'],$_POST['u_lname'],$_POST['u_addr'],$_POST['u_city'],$_POST['u_state'],$_POST['u_zip'],$_POST['u_ctry'],$_POST['cc_name'], $_POST['cc_num'], $_POST['cc_month'], $_POST['cc_year']);
$frm_msgs = array("Salutation","First Name","Last Name","Address","City","State / Province","Postal Code","Country","Card Name", "Card Number", "Expiration Month", "Expiration Year");
for( $i = 0; $i < sizeof($frm_flds); $i++ ){
if ($frm_flds[$i] == "") {
$e_msg .= $frm_msgs[$i] . " is a required field.
\n";
$order_step = 1;
}
} //end loop
//check email
if (!strstr($u_email, '@') && !strstr($u_email, '.')){
$e_msg .= "Please enter a valid email address.
\n";
$order_step = 1;
}
// if Other Amt is selected, check to see if input valid.
if ($_POST['d_amt'] == ""){ //no selection
if (!is_numeric($_POST['d_other'])){
$order_step = 1;
$e_msg .= "Please specify a valid gift amount.
\n";
}else {
$cc_amt = $_POST['d_other'];
}
} else {
$cc_amt = $_POST['d_amt'];
}
$gift_amt = "$" . $cc_amt;
//$hid_array = array("u_empphone","u_empcont","u_empname","u_gift","u_sal", "u_fname","u_lname","u_addr","u_city","u_state","u_zip","u_ctry","u_hmphone","cc_name","cc_num","cc_month","cc_year");
// $hid_flds = "";
// for ($i = 0; $i <= sizeof($hid_array); $i++) {
// $hid_flds .= "";
// }
if ($order_step == 3)
{
$trans = array($_POST['cc_num'], $cc_amt ,"","",$_POST['cc_month'],$_POST['cc_year']);
//executes the trans, use "N" to simulate failure
$cc_result = charge_cc($trans,"F");
//done execute, handle RESULT
if ($cc_result["RESULT"] == 0) {
$u_sql = "insert into userinfo (u_fname,u_minit,u_lname, u_empphone, u_empcont, u_empname, u_empmatch, u_gift, u_sal, u_addr, u_city, u_state, u_zip, u_ctry, u_hmphone,u_email, u_refer) ";
$u_sql .= "values ('{$_POST['u_fname']}','{$_POST['u_minit']}', '{$_POST['u_lname']}', '{$_POST['u_empphone']}', '{$_POST['u_empcont']}', '{$_POST['u_empname']}', '{$_POST['u_empmatch']}', '{$_POST['u_gift']}', '{$_POST['u_sal']}', '{$_POST['u_addr']}', '{$_POST['u_city']}', '{$_POST['u_state']}', '{$_POST['u_zip']}', '{$_POST['u_ctry']}', '{$_POST['u_hmphone']}','{$_POST['u_email']}', '{$_POST['refer']}')";
$u_result = mysql_query($u_sql);
$u_newid = mysql_insert_id(); //new record ID here.
//now insert transaction record into other table and use $u_newid as the foregin key.
$u_sql = "insert into trans (d_u_id,d_date, d_src, d_amt, d_ref) ";
$u_sql .= "values ('$u_newid', now(),'{$_POST['d_src']}', '$cc_amt', '{$cc_result['PNREF']}')";
$u_result = mysql_query($u_sql);
//send notification of gift
gift_notify($_POST['d_amt']);
//thank donor - updated 1/05/04
$donor_ary = array($_POST['u_sal'],$_POST['u_fname'],$_POST['u_lname'],$_POST['u_addr'],$_POST['u_city'],$_POST['u_state'],$_POST['u_zip'],$cc_amt,$_POST['u_email']);
thank_donor($donor_ary);
//when done close connection
mysql_close($conn);
} else { // transaction failed
$order_step = 1;
$e_msg = "Your credit card failed, the reason was: " . $cc_result["RESPMSG"] . "
Please try again.";
// Tell user cc failed, include why & redraw form with their input
}
}
}
else
{
$order_step = 1;
}
?>
|
| ||||||||||
Home | About the Foundation | Support the Foundation | Use of Funds | Our Boardmembers | Contact We are a registered 501(c)3 not for profit organization | |||||||||||