This script allows users to select an image and write a personalized message. It then sends a notice to the user specified email address and saves that information to a text file. The receipient then can go and access both the saved message and image from the website at a specified URL. The latest version uses a random number to improve the security. We have also improved cleaned up some problems that users have noticed with the script.
PHPCards presently uses four PHP files & one text file. You need to ensure that your site has PHP3 enabled and that you have write access to the text file. If your server isn't configured so that it recognizes both .php3 and .phtml extensions, you will need to rename the files. Also note that you will need to remove the .phps extension from each of the files below as that extension allows you to display the source, and does not parse it.
![]() In Action |
The two basic functions of a greeting card is sending & recieving cards.
|
For the most part, this is just a simple form. The only part that is really critical is that the form be posted to send.php3.
The other PHP scripts on this page are largely there to make it easier for users to modify a card or reply to a card.
This script first loads the contents of the text file into an array. It then generates a new random number and incorporates the new message into the array. This page contains a number of nested if statements before the message is sent. The script checks to see that the sender & reciever's email addresses are correct using the following:
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $remail))It then confirms that you want to send the message & then fires off a message to the recipient using:
mail(stripslashes($recipient) . "<$remail>", stripslashes($sender) . " has sent you a card", $email_message,"From: $semail \nReply-To:$semail\nX-Mailer: PHP3\r\n Errors-To: mike@flora.org");and also writes it to the text file. Each message of the text file is seperated by a carriage return. Each field of data is seperated by a ':'. If the user doesn't confirm the card they are sent back to send.phtml either with the data that they entered or to a blank message (depending on their response).
This is the simplest code of the script. This can be easily inserted into sidebars or you can choose to have it sit as its own page. Like the send.phtml script above, it is an html form. The form's "action" needs to target the receive.php3
Like send.php3, receive.php3 is the work horse of the set. This script starts by loading the text file into an array. It then takes the card number, goes to that line of the array and using
$tok = strtok($dataarray[$viewcard-1],":");This divides up the line into various fields and then proceeds to insert the data into HTML code in place of $tok. If the random number in the text file is the same as the random number provided by the user, then the card is displayed. The user is then asked if they would like to send a reply.
If you are using this script on your site, please send me your URL and please provide a link to OpenConcept. Also, if you've got improvements or suggestions for the code, please send them to me. The previous version of the script can be found here.
Todo List