%
option explicit'must be declared
'setting buffering to true
response.buffer=true
'decleration
dim useraction
dim conn
dim rs
dim sql
dim dsn
dim DownNumber
dim sql3
dim sql2
dim uemail
dim subs
dim msg
dim firstname
dim lastname
'----------------------
'get action from user
useraction=request("action")
select case useraction
case "save"
Uemail=lcase(request.form("email"))
firstname=request("firstname")
lastname=request("lastname")
subs=request.form("subs")
dsn="DBQ=" & Server.Mappath("db/subs.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
sql = "select * from emails where emails='"&Uemail&"'"
conn.open dsn
rs.open sql,conn
select case subs
'in case someOne wants to join the list
case "1"
if rs.bof and rs.eof then
sql2="insert into emails(emails,firstname,lastname) values('"&Uemail&"', '" & firstname&"', '" & lastname & "')"
conn.execute(sql2)
msg = "Thank you. Your email has been added to the Health Brief subscription list.
"
else
msg = "Thanks, but you are already registered.
"
end if
'in case someOne wants to unsubscribe
case "0"
if rs.bof and rs.eof then
msg = "You were not registered.
"
else
sql2="update emails set removed = 'yes' where emails='"&Uemail&"'"
conn.execute(sql2)
msg = "Your subscription has been deleted.
"
end if
end select
rs.close
set rs=nothing
case "friend"
dim Your_Name, Your_Email, Friends_Name, Friends_Email
Your_Name = request("Your_Name")
Your_Email = request("Your_Email")
Friends_Name = request("Friends_Name")
Friends_Email = request("Friends_Email")
dim strbody
dim sendMail1
Set sendMail1 = Server.CreateObject( "CDONTS.Newmail" )
sendMail1.From = Your_Email
sendMail1.To = Friends_Email
sendMail1.Subject = "Hi " & Friends_Name & ", I care about your health!"
sendMail1.MailFormat = 0
sendMail1.BodyFormat = 0
dim filesys, hbfile, textstream
set filesys = CreateObject ("Scripting.FileSystemObject")
set hbfile = filesys.GetFile(server.MapPath("health_brief.txt"))
set textstream = hbfile.OpenAsTextStream
strbody = textstream.Readall()
sendMail1.Body = strbody
sendMail1.Send
dim friendmsg
friendmsg = "The Health Brief has been sent to " & Friends_Name & "."
end select
%>
![]() |
|
|
|
|
|
|
![]() |
|
|