jaxdevil Posted December 18, 2007 Share Posted December 18, 2007 I have my cc authorization system create a temporary table to store cc info during the transaction with the processor. When it is done I need to display the last 4 digits of the card number on the receipt. I then save this back to the database, I can do that part, what i cannot figure out is what function strips all the data away except the last 4 digits? Anyone? I found a good one yesterday but lost it. I thought it was in the tutorials or code library but I can't find it. Anyone can point me in the right direction? Thanks in advance, SK Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/ Share on other sites More sharing options...
pocobueno1388 Posted December 18, 2007 Share Posted December 18, 2007 Use substr() <?php $number = "5588 3207 2678 6726"; $last_four = substr($number, -4); echo $last_four; //prints "6726" ?> Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-417702 Share on other sites More sharing options...
papaface Posted December 18, 2007 Share Posted December 18, 2007 Isn't there a law that prevents you from storing this information ??? Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-417705 Share on other sites More sharing options...
jaxdevil Posted December 18, 2007 Author Share Posted December 18, 2007 Yes, but its not actually 'stored, its a temporary table that last like 30 seconds, enough time to post the data to the processor, retrieve the response, pull the data back up (since the payment data is not transfered back from the processor during approval) extract the last 4 digits, and store the approval code, last 4, card type, and transaction number. (transaction number and auth code are transmitted back with approval) so the only thing we will store is the last 4 digits, which is perfectly legal. Thanks for the help man! That was the exact code I found yesterday (well almost exact, same function though) perfect! SK Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-417712 Share on other sites More sharing options...
trq Posted December 18, 2007 Share Posted December 18, 2007 Best doing this in your query. MySql has a substr function too. SELECT SUBSTR(cc,-4) as cc_tail FROM tbl Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-417732 Share on other sites More sharing options...
adam291086 Posted December 18, 2007 Share Posted December 18, 2007 sorry but i am confused. If it is ilegal to store card information how do companies know what numbers to type in at the bank, to debit your account? Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-417743 Share on other sites More sharing options...
jaxdevil Posted February 26, 2008 Author Share Posted February 26, 2008 Actually I checked, it is not illegal to store the cc number. Quote Link to comment https://forums.phpfreaks.com/topic/82197-solved-display-only-last-4-digits-of-a-database-entry/#findComment-477289 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.