phppup Posted February 27, 2012 Share Posted February 27, 2012 After submission I want to be able to pull up a customer record and the LAST 4 DIGITS of the social security number that was provided. What's the best way to do this? Am I best off having them INPUT the digits into three different fields that will load into the DB as Socxxx, Socxx, and Socxxxx, and just calling the Socxxxx field, or is there a way to 'strip' all but the last 4 digits? Quote Link to comment https://forums.phpfreaks.com/topic/257880-displaying-soc-security-number/ Share on other sites More sharing options...
ManiacDan Posted February 27, 2012 Share Posted February 27, 2012 You can use regex for this: php > $ssn = '123456789'; php > echo preg_replace('/\d{5}(\d{4})/', '*****\\1', $ssn); *****6789 Quote Link to comment https://forums.phpfreaks.com/topic/257880-displaying-soc-security-number/#findComment-1321747 Share on other sites More sharing options...
Zane Posted February 27, 2012 Share Posted February 27, 2012 I'm assuming you have the required permissions to store people's SSN... and if you do, I would have to disagree with ManiacDan on this one. It would be much better to format this string in the query so the actual SSN isn't floating around, even though the likelihood of someone grabbing the data from the script it highly unlikely, the data is still very sensitive and must be handled that way. So, something like this should work SELECT RIGHT(ssn_number ,4) Quote Link to comment https://forums.phpfreaks.com/topic/257880-displaying-soc-security-number/#findComment-1321753 Share on other sites More sharing options...
ManiacDan Posted February 27, 2012 Share Posted February 27, 2012 Zane has a point about the query, the lower the level of obfuscation, the better. I didn't realize this was in the mysql section, otherwise I would have provided a MySQL response. Quote Link to comment https://forums.phpfreaks.com/topic/257880-displaying-soc-security-number/#findComment-1321754 Share on other sites More sharing options...
Pikachu2000 Posted February 28, 2012 Share Posted February 28, 2012 If you don't have an excellent grasp of database and web application security, storing SSNs is not a good idea at all. Quote Link to comment https://forums.phpfreaks.com/topic/257880-displaying-soc-security-number/#findComment-1321941 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.