PHP Validate Email Address

Mar 08

If you have ever needed to validate an email address to see if the format is good then heres a nice function that does that and more up to and including checking the DNS of the domain of the email address to see if its actually a real domain. Though a lot of people will insist that a single one line regex with preg_match() will be more than enough to suffice most...

Read More

PHP Strong Password

Mar 08

If you want to prompt your users to create password that is a certain length more or less, that is also strong by today’s definition then here is a good example. This can be elaborated on even more but for common use in most practices this is more than enough. You can comment out like I have in the example below one or more if-else statements if you wish to not...

Read More

PHP Verify a Dollar Amount

Mar 08

Just a simple function to see if an input numeric value is actually a US Dollar (USD) format Example: Two Dollar Amounts provided to the script.. 1502.38 and 10O.00 Good: 1,502.38 Bad: 10O.00 came back false. function verifyMoney($what){ if (preg_match('#^[0-9]+(\.[0-9]{0,2})?$#', $what)){ $monkey = number_format($what,...

Read More

PHP Validate Credit Card format

Mar 08

Are you in a bind trying to figure out if that user input credit card number is valid as far as format goes. Not just length but the actual combination of numbers as well? Well then here is a quickie solution. Due to the sensitive nature of the topic though I will omit the example portion of this code but the concept of use in this particular version is take a select...

Read More

PHP Last day of Month

Mar 08

Need to get the last day of any given month? Everyone occasionally does, here’s how. Example: 02-2012 = 2012-02-29 05-2012 = 2012-05-31 function lastday($month = '', $year = '') { if(empty($month)) { $month = date('m'); } if(empty($year)) { $year =...

Read More