iarp Posted June 26, 2012 Share Posted June 26, 2012 Long story short, some people have been storing credit cards in open note areas of a program they bought. It runs off of MSSQL. MSSQL has no way of finding all credit card numbers and masking them with X's. So I've resorted to using PHP. The area where the CC numbers were stored are the notes area, a place they also store the order details and much more. # Remove all spaces, dashes, and extra html from the note. $note = trim(strip_tags(str_replace(array('-', ' ', 'P,UL,OL,DL,DIR,MENU,PRE{margin:0auto;}'), '', $row['notes']))); A var_dump on $note results in string(22) "4123123412341234 blah" RegEx to find the cards # RegEx check against Visa, Mastercard, Amex, if(preg_match('/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/i', $note)) { $found[] = $row['recid']; } After the while loop, i want to see what is in $found print_r($found); # Results in Notice: Undefined variable: found in ..... test.php on line # I have tried many regex strings trying to get preg_match to work. The idea is, once the recid is found to contain a credit card number i will then loop through $found again and update each row as necessary. Am i using preg_match in an incorrect way? If i edit the note in the program and remove the blah so it's just the CC number it returns positive and $found gets the recid. But as soon as anything else is entered it fails and no recid. Quote Link to comment https://forums.phpfreaks.com/topic/264815-find-credit-card-numbers-stored-in-large-body-of-text-and-replace-with-xs/ Share on other sites More sharing options...
darkfreaks Posted June 26, 2012 Share Posted June 26, 2012 http://brett.batie.com/software-development/post-about-format-credit-card-with-xs-and-dashes-using-php/ Quote Link to comment https://forums.phpfreaks.com/topic/264815-find-credit-card-numbers-stored-in-large-body-of-text-and-replace-with-xs/#findComment-1357180 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.