blocking the first five numbers in a SS#, leaving the last four

Hi, I have spent hours trying to figure out how to only allow the last four digits on the social security number to appear when the user submits the form. If any one could please help me I would be very greatful. I have attached both my php and my html script so know one thinks I'm not doing the work.

[php]

<?php $firstName = $_POST['fName']; $lastName = $_POST['lName']; $SocialSecuritynumber = $_POST['Number']; echo "Thank you for filling out my form, ".$firstName." ".$lastName ." ".$SocialSecuritynumber ."."; ?>

[/php]

Submittal Form

First Name:

Last Name:

Social Security number:

   

[php] [/php]

Hi there,

Try this:
[php]echo “Thank you for filling out my form,
“.$firstName.” “.$lastName .” #####”.substr($SocialSecuritynumber,5).".";
[/php]

i wrote a little snippet for you, i hope it is what you are looking for :smiley:
[php]

<?php $SocialSecuritynumber = /* $_POST['Number'];*/ 12345677890; // your full number (i used a temp) $len = strlen($SocialSecuritynumber); // count how long the string is? $SocialSecuritynumber = substr($SocialSecuritynumber, ($len-4), 4); // -4 from the total count and chop it echo $SocialSecuritynumber; // outputs: 7890 for this example. ?>

[/php]

Thank you so much, that works great. Have a nice day.
Sponsor our Newsletter | Privacy Policy | Terms of Service