Kevin Pirnie' Articles

    Home / Archives for December 2012
The following code will allow you to send an email, with a file attachment without the need for a 3rd party library. This code assumes that you already have the upload and form fully operational. function XMail( $from, $fromname, $to, $subj, $text, $filename) { //Open our file, rb = windows machine, you may need to change this to r for linux $f = fopen($filename,"rb"); //let's get a uniqueidentifier $un = strtoupper(uniqid(time())); //Set the from name and address $head = "From: $fromname <$from>n"; //set who we are sending this to $head .= "To: $ton"; //set the subject $head .= "Subject: $subjn"; //just for s's and giggles $head .= "X-Mailer: PHPMail Tooln"; //set the reply to address $head .= "Reply-To: $fromn"; //now we set our mime types,… Read More
I recently needed to add in a credit card expiration date year selector, and just wanted to share the code I used to populate the options. As always, please use this as you see fit. function ExpYear(){ //Get today's Year $curYear = date("Y"); //Just in case it's needed, get 2 years ago $sYear = $curYear - 2; //Now let's add 10 years $eYear = $curYear + 10; $ret = ''; //For $1 = 2 years ago, to 10 years from now, increment 1 year and populate our return variable for($i = $sYear; $i < $eYear; ++$i){ $ret .= '<option value="' . $i . '">' . $i . '</option>'; } return $ret; } Read More