<?php
if ( isset($_POST['btnSubmit']) ) {
// gather card info
// gather card info
$transaction->amount ='9.99';
$transaction->card_num =$_POST['card_num'];
$transaction->exp_date =$_POST['exp_date'];
// gather card info
// gather card info
//capture info
$response = $transaction->authorizeAndCapture();
//capture info
//check if approved
//check if approved
if($response->approved){
echo "<h1>Success! The test credit card has been charged!</h1>";
echo "Transaction ID: ". $response->transaction_id;
//check if approved
//check if approved
// if approved insert into sql data base
// if approved insert into sql data base
$query = "INSERT INTO payments (card_num,exp_date) VALUES ('$card_num','$exp_dat')";
$result = mysql_query($query);
// if approved insert into sql data base
// if approved insert into sql data base
}else{
echo $response->error_message;
}
}
?>
I am trying to run a payment integration code, and when the payment is approved, I can't insert the payment details into MySQL table. It says:
Undefined variable: exp_dat" " Undefined variable: card_num.
I am not sure how to define it because I can't put $
before card_num
in the $transaction->card_num =$_POST['card_num'];
.
I also can't insert the transaction id in there.
Thanks