|
sgreen0 -> RE: help with insert database script (1/6/2005 12:44:52)
|
Thanks, Brian! Here is the code as it is: <html>
<head>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../../anmt_stylesheet.css">
<meta http-equiv="Content-Language" content="en-us">
<%
If Request.Form("FirstName")<>"" Then
Session("uFirstName") = Request.Form("FirstName")
If Request.Form("LastName")<>"" Then
Session("uLastName") = Request.Form("LastName")
Else
Session("uFirstName") = Session("uFirstName")
Session("uLastName") = Session("uLastName")
End If
End If
Function ParseBody(strText)
'=================================================
' This function replaces the Chr(13) with a <br>
' tag in whatever string is passed to it.
'=================================================
strText = Replace(strText, Chr(13), "<br>")
ParseBody = strText
End Function
If Request.Form("FirstName")<>"" Then
Dim myConnString
Dim myConnection
Dim mySQL
MyConnString = Application("online_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString
mySQL= "INSERT INTO OnLineContacts "
mySQL= mySQL & "(FirstName,LastName,Address,City,State,Zip,HomePhone,Cellphone,Email,Source,Notes) "
mySQL= mySQL & "VALUES ('" & Request.Form("FirstName") & "','"
mySQL= mySQL & Request.Form("LastName") & "','"
mySQL= mySQL & Request.Form("Address") & "','"
mySQL= mySQL & Request.Form("City") & "','"
mySQL= mySQL & Request.Form("State") & "','"
mySQL= mySQL & Request.Form("Zip") & "','"
mySQL= mySQL & Request.Form("HomePhone") & "','"
mySQL= mySQL & Request.Form("CellPhone") & "','"
mySQL= mySQL & Request.Form("Email") & "','"
mySQL= mySQL & Request.Form("Source") & "','"
mySQL= mySQL & Request.Form("Background") & "')"
myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing
End If
'===================================================================
' Send the results to e-mail.
'===================================================================
If Request.Form("FirstName")<>"" Then
Function die(strInput)
response.write strInput
response.end
End Function
'change to address of your own SMTP server
strHost = "mail.anmt.org"
strReturn = Request.Form("Return")
strBody = ""
strFirstName = trim(Request.Form("FirstName"))
if not strFirstName = "" then
strBody = strBody & "First Name: " & strFirstName & vbcrlf & vbcrlf
end if
strLastName = trim(Request.Form("LastName"))
if not strLastName = "" then
strBody = strBody & "Last Name: " & strLastName & vbcrlf & vbcrlf
end if
strAddress = trim(Request.Form("Address"))
if not strAddress = "" then
strBody = strBody & "Address: " & strAddress & vbcrlf & vbcrlf
end if
strCity = trim(Request.Form("City"))
if not strCity = "" then
strBody = strBody & "City: " & strCity & vbcrlf & vbcrlf
end if
strState = trim(Request.Form("State"))
if not strState = "" then
strBody = strBody & "State: " & strState & vbcrlf & vbcrlf
end if
strZip = trim(Request.Form("Zip"))
if not strZip = "" then
strBody = strBody & "Zip: " & strZip & vbcrlf & vbcrlf
end if
strHomePhone = Cstr(trim(Request.Form("HomePhone")))
if not strHomePhone = "" then
strBody = strBody & "Home Phone: " & strHomePhone & vbcrlf & vbcrlf
end if
strCellPhone = Cstr(trim(Request.Form("CellPhone")))
if not strCellPhone = "" then
strBody = strBody & "Cell Phone: " & strCellPhone & vbcrlf & vbcrlf
end if
strEmail = trim(Request.Form("email"))
if not stremail = "" then
strBody = strBody & "E-Mail: " & strEmail & vbcrlf & vbcrlf
end if
strEmailConfirm = trim(Request.Form("EmailConfirm"))
if not strEmailConfirm = "" then
strBody = strBody & "E-Mail Confirmation: " & strEmailConfirm & vbcrlf & vbcrlf
end if
strSource = trim(Request.Form("Source"))
if not strSource = "" then
strBody = strBody & "Source: " & vbcrlf & strSource & vbcrlf
end if
strBackground = trim(Request.Form("Background"))
if not strBackground = "" then
strBody = strBody & "Background: " & vbcrlf & strBackground & vbcrlf
end if
If Request.Form("FirstName")<>"" Then
Session("uFirstName") = Request.Form("FirstName")
Session("uLastName") = Request.Form("LastName")
Else
Session("uFirstName") = Session("uFirstName")
Session("uLastName") = Session("uLastName")
End If
'////////////////////////
'die strBody
'////////////////////////
Set Mail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
Mail.Host = strHost
Mail.From = trim(Request.Form("Email")) ' From address
Mail.FromName = trim(Request.Form("FirstName" & "LastName")) ' optional
Mail.AddAddress "academyonline@anmt.org"
' message subject
Mail.Subject = "Online Registration"
' message body
Mail.Body = strBody
strErr = ""
bSuccess = False
'On Error Resume Next ' catch errors
Mail.Send ' send message
If Err <> 0 Then ' error occurred
strErr = Err.Description
Response.Write "halted : " & strErr
'else
' bSuccess = True
' Response.Redirect(strReturn)End If
End If
End If
%>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="97%" height="234">
<tr>
<td width="26%" rowspan="2" valign="top" height="234">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="23%" height="495">
<tr>
<td width="25%" height="108">
<!--webbot bot="Include" U-Include="online_nav_bar.htm" TAG="BODY" --></td>
</tr>
</table>
</td>
<td width="75%" height="1">
<p align="center" style="margin-top: 0; margin-bottom: 0">
<img border="0" src="images/register.gif" align="center"></td>
</tr>
<tr>
<td width="75%" height="352" valign="top">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="91">
<tr>
<td colspan="2" height="24">
<p style="margin-left: 20; margin-right: 20; margin-top: 6; margin-bottom: 0">
<font face="Arial Rounded MT Bold">
<% response.write Session("uFirstName")%>, now tell us about the course you wish to
register for:</font></p>
</td>
</tr>
<tr>
<td height="1" valign="top">
<form method="POST" action="--WEBBOT-SELF--">
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><p style="margin-left: 20; margin-right: 20; margin-top: 12; margin-bottom: 0">
<font face="Arial Rounded MT Bold">Course Names:</font></td>
<td height="1" valign="top">
<p style="margin-top: 12">
<nobr>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT CourseID, CourseName FROM OnLineCourses ORDER BY CourseName ASC"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="online"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="CourseName"
fp_sMenuValue="CourseName"
fp_sColTypes="&CourseID=3&CourseName=202&CourseFee=6&"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<select NAME="CourseName" SIZE="1">
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"CourseName")%></option>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</select>
<% Session("uCourseName") = Request.Form("CourseName") %>
<%
If Request.Form("CourseName") = "Advanced Curriculum" Then
Session("uAccessLevel") = "Advanced"
End If
If Request.Form("CourseName") = "Book Lab" Then
Session("uAccessLevel") = "Book"
End If
dim vAccessLevel
If Request.Form("CourseName") = "Songwriting Lab" Then
Session("uAccessLevel") = "Song"
End If
If Request.Form("CourseName") = "Core Curriculum" Then
Session("uAccessLevel") = "Core"
End If
If Request.Form("CourseName") = "Lyric Lab" Then
Session("uAccessLevel") = "Lyric"
End If
If Request.Form("CourseName") = "Music Lab" Then
Session("uAccessLevel") = "Music"
End If
%>
</nobr>
<input type="submit" value="Select" name="B1">
<p style="margin-top: 12">
</td>
</tr>
<tr>
<td height="1" valign="top">
<p style="margin-left: 20; margin-right: 20; margin-top: 0; margin-bottom: 12">
<font face="Arial Rounded MT Bold">Tuition Amount:</font></p>
</td>
<td height="1" valign="top">
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT CourseID, Format(CourseFee, 'Currency') AS Amount FROM OnLineCourses WHERE (CourseName = '::CourseName::')"
fp_sDefault="CourseName=0"
fp_sNoRecords="No records returned."
fp_sDataConn="online"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice="Amount"
fp_sMenuValue="Amount"
fp_sColTypes="&Amount=202&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=1
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<p style="margin-top: 0; margin-bottom: 12">
<%=FP_FieldVal(fp_rs,"Amount")%></p>
<% Session("uAmount") = FP_FieldVal(fp_rs,"Amount") %>
<% Session("uCourseID") = FP_FieldHTML(fp_rs,"CourseID") %>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</td>
</tr>
<tr>
<td height="1" valign="top" colspan="2">
<% response.write Session("uFirstName")%>
<% response.write Session("uCourseName")%>
<% response.write Session("uCourseID")%>
<% response.write Session("uAmount")%>
<% response.write Session("uAccessLevel")%>
<%
If Session("AccessLevel") <>"" Then
Dim myConnString2
Dim myConnection2
Dim mySQL2
MyConnString2 = Application("online_ConnectionString")
Set myConnection2 = Server.CreateObject("ADODB.Connection")
myConnection2.Open myConnString2
mySQL2= "INSERT INTO LoginValues"
mySQL2= mySQL2 & "(AccessLevel,CourseID,CourseName) "
mySQL2= mySQL2 & "VALUES ('" & Session("uAccessLevel") & "','"
mySQL2= mySQL2 & Session("uCourseID") & "','"
mySQL2= mySQL2 & Session("uCourseName") & "')"
response.write mySQL2
response.end
myConnection2.Execute mySQL2
myConnection2.Close
Set myConnection2 = Nothing
End If
%>
<p align="center" style="margin-top: 12"><font face="Arial"><b>When you click
the PayPal logo you will be
directed to PayPal to make your payment. Once you submit your payment, you will be
directed the Login Registration Page so you can choose a Login User Name
and Password. Then you may begin your curriculum.
Enjoy!</b></font>
<p align="center">
<a href="Paypal.asp?Amount=<%=Session("uAmount")%>&CourseName=<%=Session("uCourseName") %>&CourseID=<%=Session("uCourseID") %>&AccessLevel=<%=Session("uAccessLevel")%>">
<img border="0" src="images/icon_mastercard.gif"><img border="0" src="images/icon_visa.gif"><img border="0" src="images/icon_paypal.gif"><img border="0" src="images/icon_echeck.gif"><img border="0" src="images/icon_discover.gif"><img border="0" src="images/icon_amex.gif"></a><p align="center">
<img border="0" src="images/logoPaypal.gif"><p align="center">
<font face="Verdana, Arial, sans-serif" size="3">
</tr>
</table>
</td>
</tr>
</table>
</body>
</html> As I said, I understand why the session variables aren't filled until the selection is amde from the drop down (except for FirstName, which is already displayed at the dop of the page). But why the HTML isn't showing... Stephen
|
|
|
|