PHP MySQL: decrypt a column value from a MySQL row that was encypted upon insertion and parse to JSON -
everything working, want decrypt db column containing credit card number database following example:
$decp = $crypt->decrypt($encp);
the row in question is:
'number' => $row['cardnumber'],
the entire code is:
// cards $jsonresult = $conn->query("select nameoncard, cardnumber, cardtype, carddate, ccvcode cy_user_credit_cards accountnumber='$accountnumber'"); $creditcard = []; while ($row = mysqli_fetch_assoc($jsonresult)) { array_push($creditcard, [ 'name' => $row['nameoncard'], 'number' => $row['cardnumber'], 'type' => $row['cardtype'], 'date' => $row['carddate'], 'ccv' => $row['ccvcode'] ]); } // convert array json string , echo $ccjson = json_encode($creditcard); echo $ccjson; $conn->close();
i think want this:
// cards $jsonresult = $conn->query("select nameoncard, cardnumber, cardtype, carddate, ccvcode cy_user_credit_cards accountnumber='$accountnumber'"); $creditcard = []; while ($row = mysqli_fetch_assoc($jsonresult)) { array_push($creditcard, [ 'name' => $row['nameoncard'], 'number' => $crypt->decrypt($row['cardnumber']), 'type' => $row['cardtype'], 'date' => $row['carddate'], 'ccv' => $row['ccvcode'] ]); } // convert array json string , echo $ccjson = json_encode($creditcard); echo $ccjson; $conn->close();
keep in mind, not want store of these credit card details in database if not absolutely necessary. urge elsewhere handle credit card payments.
Comments
Post a Comment