Newbie question

B

Bob Leffew

I am new at using VB Script in an ASP page using Dreamweaver MX

I had tried to build a Login page that verified that the users email address
was not in a database, then insert the data from the form into a databas
plus email the results back to me.

Everything worked fine execpt for the emailing part.

So I take the email out of the registration page, set a session variable to
the email address, and redirect to a page called LSIEmailForm.

In this page I set up a form with Hidden fields thats poplulates each field
from reading the database from the session variable which I set in the
previous page with the email address.

What I need to do is 1) Read the database 2)email the results to myself 3)
then redirect automatically to a Registration Successfull page. (This needs
to be a pass thru page from Registration to Registration successfull)

I have the code below but I cant get it to work.

Any suggestions?

<%@LANGUAGE="VBSCRIPT"%>

'*************
'Read Database from Session Variable set from previous page
'*************

<!--#include file="../Connections/cnLSI.asp" -->
<%
Dim rsLSI__MMColParam
rsLSI__MMColParam = "1"
If (Session("svEmailAddress") <> "") Then
rsLSI__MMColParam = Session("svEmailAddress")
End If
%>
<%
Dim rsLSI
Dim rsLSI_numRows

Set rsLSI = Server.CreateObject("ADODB.Recordset")
rsLSI.ActiveConnection = MM_cnLSI_STRING
rsLSI.Source = "SELECT * FROM UserLog WHERE EmailAddress = '" +
Replace(rsLSI__MMColParam, "'", "''") + "'"
rsLSI.CursorType = 0
rsLSI.CursorLocation = 2
rsLSI.LockType = 1
rsLSI.Open()
rsLSI_numRows = 0
%>
<%

'**********
' *** Send Form Values From Same Page to Webmaster - ASPMail_111
'**********

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

' Specify a valid sender's address
Mailer.FromAddress= "(e-mail address removed)"
' Specify a valid SMTP server
Mailer.RemoteHost = "mail-fwd.bellsouth-hosting.net"
Mailer.AddRecipient "", "(e-mail address removed)"
Mailer.Subject = "LSI Registration"
Mailer.BodyText = Chr(13) & Chr(10) &_
"EmailAddress" & ": " & cStr(Request("EmailAddress")) & Chr(13) & Chr(10) &_
"Password" & ": " & cStr(Request("Password")) & Chr(13) & Chr(10) &_
"RegistrationDate" & ": " & cStr(Request("RegistrationDate")) & Chr(13) &
Chr(10) &_
"FirstName" & ": " & cStr(Request("FirstName")) & Chr(13) & Chr(10) &_
"LastName" & ": " & cStr(Request("LastName")) & Chr(13) & Chr(10) &_
"Title" & ": " & cStr(Request("Title")) & Chr(13) & Chr(10) &_
"Company" & ": " & cStr(Request("Company")) & Chr(13) & Chr(10) &_
"Address" & ": " & cStr(Request("Address")) & Chr(13) & Chr(10) &_
"Address2" & ": " & cStr(Request("Address2")) & Chr(13) & Chr(10) &_
"City" & ": " & cStr(Request("City")) & Chr(13) & Chr(10) &_
"State" & ": " & cStr(Request("State")) & Chr(13) & Chr(10) &_
"ZipCode" & ": " & cStr(Request("ZipCode")) & Chr(13) & Chr(10) &_
"Country" & ": " & cStr(Request("Country")) & Chr(13) & Chr(10) &_
"WorkPhone" & ": " & cStr(Request("WorkPhone")) & Chr(13) & Chr(10) &_
"WorkFax" & ": " & cStr(Request("WorkFax")) & Chr(13) & Chr(10) &_
"MobilePhone" & ": " & cStr(Request("MobilePhone"))
Mailer.SendMail
Response.Redirect "LSIRegistrationSuccessful.asp"
End If
%>
</script>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">
<div align="left">
<form ACTION="" METHOD="" name="form1" target="_blank" onSubmit="">

<div align="left">
<p>&nbsp;</p>
<table width="100%" border="0" align="left" cellpadding="4"
cellspacing="5">
<tr align="left" valign="middle">
<td width="18%"><div align="right"><strong></strong></div></td>
<td width="82%" colspan="2"><div align="left"><strong><font
color="#000099" size="1" face="Verdana, Arial, Helvetica, sans-serif">
<input name="EmailAddress" type="hidden" id="EmailAddress"
value="<%=(rsLSI.Fields.Item("EmailAddress").Value)%>">
<input name="Password" type="hidden" id="Password"
value="<%=(rsLSI.Fields.Item("Password").Value)%>">
<input name="RegistrationDate" type="hidden"
id="RegistrationDate"
value="<%=(rsLSI.Fields.Item("RegistrationDate").Value)%>">
<input name="FirstName" type="hidden" id="FirstName"
value="<%=(rsLSI.Fields.Item("FirstName").Value)%>">
<input name="LastName" type="hidden" id="LastName"
value="<%=(rsLSI.Fields.Item("LastName").Value)%>">
<input name="Title" type="hidden" id="Title2"
value="<%=(rsLSI.Fields.Item("Title").Value)%>">
<input name="Company" type="hidden" id="Company"
value="<%=(rsLSI.Fields.Item("Company").Value)%>">
<input name="Address" type="hidden" id="Address"
value="<%=(rsLSI.Fields.Item("Address").Value)%>">
<input name="Address2" type="hidden" id="Address2"
value="<%=(rsLSI.Fields.Item("Address2").Value)%>">
<input name="City" type="hidden" id="City"
value="<%=(rsLSI.Fields.Item("City").Value)%>">
<input
name=State type=hidden
value="<%=(rsLSI.Fields.Item("State").Value)%>">
<input name="ZipCode" type="hidden" id="ZipCode"
value="<%=(rsLSI.Fields.Item("ZipCode").Value)%>">
<input name="Country" type="hidden" id="Country"
value="<%=(rsLSI.Fields.Item("Country").Value)%>">
<input name="WorkPhone" type="hidden" id="WorkPhone"
value="<%=(rsLSI.Fields.Item("WorkPhone").Value)%>">
<input name="WorkFax" type="hidden" id="WorkFax"
value="<%=(rsLSI.Fields.Item("WorkFax").Value)%>">
<input
name=MobilePhone type=hidden id="MobilePhone"
value="<%=(rsLSI.Fields.Item("MobilePhone").Value)%>">
</font></strong></div></td>
</tr>
</table>
<p>&nbsp;</p>
</div>
</form>
&nbsp;</div>
</body>
</html>
<%
rsLSI.Close()
Set rsLSI = Nothing
%>
 
D

Dave Anderson

Bob Leffew said:
Does this mean I dont get any help?

That depends on the folks in all of the other newsgroups you posted similar
messages to.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
R

Ray at

Sure, you can still get help. :] But help us help you a little more. Tell
us what you mean when you say you cannot get the page to work. What part is
not working? Do you get an error?

While I'm here, here are a couple of suggestions:

1. Instead of Chr(13) & Chr(10), use vbCrLf
2. Instead of Request("fieldname"), use Request.Form("fieldname")
''assuming values are coming from a posted form
3. Don't use Dreamweaver. :]

Ray at work
 
D

Dave Anderson

Bob Leffew said:
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

This doesn't appear to be an IIS/ASP issue so much as an issue with the
SMTPsvg.Mailer component. Why don't you seek help from the vendor that
supplied the component?

Most folks here know something about using CDO, on the other hand, so if you
need help with CDO.Message, I'm sure you could get plenty of it here. Either
way, this should be useful:

http://aspfaq.com/show.asp?id=2119



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
B

Bob Leffew

Can you suggest where I can read on how to:

1) Read a Database based on a sesson variable.
( I think I did this successfully)

2) Email the contents of the record from the database.
(This part I am not sure of)

What should I use if I dont use Macromedia MX?

Bob
 
T

Tom B

3) The reason for the Macromedia comment, is that it creates hard to follow
and inefficient code.
2) Start here http://www.aspfaq.com/show.asp?id=2026 for example code.
1) Here's a simple example

<%
'Assume that a Session variable named "UserID" contains a value

Dim lngUserID
lngUserID=Request.Session("UserID")
if (isNumeric(lngUserID)) AND (len(lngUserID)>0) then 'Make sure
there's a value and it's numeric
lngUserID=CLng(lngUserID) 'Convert it from a string subtype
to a long subtype
end if

Dim RS
Dim CN
Dim sConnectionString
Dim sSQL

sConnectionString="" 'see www.connectionstrings.com for the proper code
Set CN=CreateObject("ADODB.Connection")
CN.Open sConnectionString 'Open a connection to the database

sSQL="SELECT FName, LName FROM tblUsers WHERE UserID=" & lngUserID
'Create a SQL query
Set RS=CN.Execute(sSQL) 'Execute the query returning a recordset that
goes into the RS object
if not RS.EOF then 'check if the RS is at the EndOfFile - if it is
there are no records
Response.Write "The user's name is " & RS.Fields("FName") & " " &
RS.Fields("LName") 'Write out the results.
end if
Set RS=nothing 'Set the RS object to nothing
CN.Close 'Close the connection
Set CN=nothing 'Set the CN object to nothing
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top