Sending Digital PostCards with ASP and the free component ASPEmail from Persits software.
By Joao Vieira
What is a Digital Postcard?
A digital postcard is a image a net surfer picks out, along with an accompanying personal message. The net surfer "sends" the postcard by supplying a friend's email address. A link is then emailed to the address supplied. The link takes the receiver of the digital postcard to the site which displays the image and contains the personal message.
First you must create a database to house the information for the postcards. (I use a DataBase to put the PostCards information so that when a person gets the mail with the post card only have to click on the link and the page apears, goin to DB to get the Data. So here it is the structure of my DataBase (you can make your own, with more information if you intend to.
Postal
ID_POSTAL Autonumber
passw integer
postal Text
nameto Text
namefrom Text
emailfrom Text
emailto Text
Message Text
Data Text
For the digital postcard system to work, you will need a number of images for the postcards. In my example I have six unique postcards, and 12 images for the postcards: a thumbnail and normal size image for each postcard. I also use images for buttons, the main ones being View, Send, and Repeat.
Concerning the code, I want to warn you that I am not going to be going deep into the HTML aspect; I will concentrate on the ASP. If you have any questions about this article, please contact me.
You will have to make an HTML form. I used the POST method, because I don't like to see all ofthe information submitted in the address link box. (Related Article! Passing Data Between ASP Pages)
FILE: makin.html
This file contains the form where we get all of the information from the user. This information will be used to make the digital postcard.
<form
name="postalsent"
method="post"
action="view.asp?fromn=seeit"
target="_self"
>
.....
<td width="24" valign="bottom">
<font face="Arial">
<input type="radio" value="postal1" name ="R1">
</font>
</td>
<td width="140">
<font face="Arial">
<IMG border=2 height=86 src="images/postal1.gif" width=134>
</font>
</td>
<td width="12" valign="bottom">
<font face=3D"Arial">
<input type="radio" value="postal2" name ="R1">
</font>
</td>
<td width="151">
<font face="Arial">
<IMG border=2 height=87 src="images/postal2.gif" width=134>
</font>
</td>
</tr>
<tr>
<td width="24" valign="bottom">
<font face="Arial">
<input type="radio" value="postal3" name="R1">
</font>
</td>
<td width="140">
<font face="Arial">
<IMG border=2 height=88 src="images/postal3.gif" width=135>
</font>
</td>
<td width="12" valign="bottom">
<font face="Arial">
<input type="radio" value="postal4" name="R1">
......
<INPUT name="nameto" size=18 style="LEFT: 1px; TOP: 2px">
<input name="emailto" size="18">
<input name="namefrom" size="18">
<input name="emailfrom" size="18">
<TEXTAREA cols=18 name=message rows=2></TEXTAREA>
<input type="image" name="bseeit" src="images/seesentbotton.gif"
border=0 height=51 width=110>
<td width="32%">
<a href="makin.htm">
<img border=0 height=53 src="images/resetbotton.gif" width=41>
</a>
</td>
......
As you see in this example I use an image for Submit Button, and another image for reset button, at the reset button I made a reload of the page (refresh) that really cleans all the fields.
At action="view.asp?fromn=seeit" I use fromn to know if view.asp is being accessed from the creation phase or from the person that wants to view the digital postcard that was sent to them. I chose to set fromn to Seeit if we are still in the creation phase, and out if we are wanting to view the postcard.
In the file makin.html all we want to do is to send the information collected in the above FORM. The fields that i'm using are the ones named above: R1, nameto, mailto, namefrom, emailfrom.
FILE: view.asp
This the the important part, here we will see if there is a person previewing the card before sending it, or a person viewing card already sent. We will take all the information sent by the POST form of the previous file.
<%
Dim fromn
Dim ident
Dim psw
' erring tells us if the card already
' exists. By default, we assum it does.
Dim erring
' I normaly use 0 and 1 for boolean,
' cause it is quicker
erring = 0
' Receiving the information
' from the link that led to this file;
' this one tell us
' what kind of access we're doing
fromn = Request.QueryString("fromn")
' here we take the ID from the post card,
' for us to know wich card we want to see.
' All this information will be compared with
' the one in the database.
ident = Request.QueryString("ident")
' This is the password
' We do not want a person that knows there exists a
' postcard with ID 13 tries to see one with ID 12.
' We will generate a random number for the password
psw = Request.QueryString("psw")
if fromn = "seeit" then
' If we just want to see the preview
' I have created sessions to keep the information,
' so that I can view the data at any step
session("postal") = Request.form("R1")
session("namefrom") = Request.form("namefrom")
session("emailfrom") = Request.form("emailfrom")
session("nameto") = Request.form("nameto")
session("emailto") = Request.form("emailto")
session("message") = Request.form("message")
else
'Someone is wanting to see an already sent card
'Open the DB connection
Set Conn = Server.CreateObject("ADODB.Connection")
' The DSN you made for the database
conn.open "DSN=postal;"
'Create a recordset
Set rs = Server.CreateObject("ADODB.Recordset")
' This is asimple SQL statement that see if the ID and
' password are connected in the DB
SQLStmt = "SELECT * FROM postal WHERE ID_POSTAL = " & _
&
[1] [2] [3] [4] 下一页