RedBravo
09-14-2005, 03:27 PM
Hi,
Need some help please changing a script from CDONTS mail to CDOSYS mail.
Can someone have a look at these two scripts, register.asp and storefuncs.asp and tell me what i am doing wrong. I want to generate an email to customers confirming that they have registered. Everything else in the scripts works fine updating database etc but won't send an email - I don't get an error message either.
Thanks in advance
Rob
storfuncs.asp
<%
'==========================
' Common Functions
'==========================
FUNCTION fixQuotes( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION
SUB addCookie( theName, theValue )
Response.Cookies( theName ) = theValue
Response.Cookies( theName ).Expires = "July 31, 2010"
Response.Cookies( theName ).Path = "/"
Response.Cookies( theName ).Secure = FALSE
END SUB
FUNCTION checkpassword( byVal username, byVal password, byRef Con )
sqlString = "SELECT user_id FROM users " &_
"WHERE user_username='" & username & "' " &_
"AND user_password='" & password & "'"
SET RS = Con.Execute( sqlString )
IF RS.EOF THEN
checkpassword = - 1
ELSE
checkpassword = RS( "user_id" )
addCookie "username", username
addCookie "password", password
END IF
END FUNCTION
FUNCTION SELECTED( firstVal, secondVal )
IF cSTR( firstVal ) = cSTR( secondVal ) THEN
SELECTED = " SELECTED "
ELSE
SELECTED = ""
END IF
END FUNCTION
SUB errorForm( errorMSG, backpage )
%>
<html>
<head><title>Problem</title></head>
<body bgcolor="lightyellow">
<center>
<table width="500" border=1
cellpadding=5 cellspacing=0>
<tr>
<td>
<font face="Arial" size="3" color="darkblue"><b>
There was a problem with the information you entered:
</b></font>
<font size="2" color="red"><b>
<br><%=errorMSG%>
</b></font>
<br>
<form method="post" action="<%=backpage%>">
<input name="error" type="hidden" value="1">
<% formFields %>
<input type="submit" value="Return">
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
<%
Response.End
END SUB
SUB formFields
FOR each item in Request.Form
%>
<input name="<%=item%>" type="hidden"
value="<%=Server.HTMLEncode( Request( item ) )%>">
<%
NEXT
END SUB
'===========================
' Registration Functions
'===========================
SUB sendNewUserMail(sUserName, sUserMail, fHtml)
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
Dim sSql
Dim objMail
Set newMailObj = CreateObject("CDO.Message")
objMailObj.From = "sales@mybusiness.com"
objMailObj.To = sUserMail
objMailObj.Subject = "mybusiness.com.au"
if fHtml = "0" then
objMail.BodyFormat = CdoBodyFormatText
objMail.MailFormat = CdoMailFormatMime
sMailBody = "Dear " & sUserName & "," & vbNewLine & vbNewLine
sMailBody = sMailBody & " Thank you for registering at our site!" & vbNewLine & vbNewLine
sMailBody = sMailBody & " We look forward to serving you in the future. "
sMailBody = sMailBody & "Visit us again soon at http://www.mysite.com." & vbNewLine & vbNewLine
sMailBody = sMailBody & "Sincerely yours," & vbNewLine & vbNewLine
sMailBody = sMailBody & "David," & vbNewLine
sMailBody = sMailBody & "CEO."
objMail.TextBody = sMailBody
else
objMail.TextBodyFormat = CdoBodyFormatHTML
objMail.MailFormat = CdoMailFormatMime
objMail.ContentBase = "http://www.mysite.com.au/"
objMail.ContentLocation = "????"
sMailBody = "<HTML><HEAD><TITLE>Thanks from mycompany.com</TITLE></HEAD>"
sMailBody = sMailBody & "<BODY><table width=""640"" border=""0"" bgcolor=""#ffffff"" cellspacing=""0"" cellpadding=""0"">"
sMailBody = sMailBody & "<tr><td colspan=""2""><hr width=""640""></td></tr></table>"
sMailBody = sMailBody & "<font face=""Arial"" size=""2""><p>Dear " & sUserName & ", "
sMailBody = sMailBody & "<p>Thank you for registering at our site!<p>We look forward to serving you in the future. "
sMailBody = sMailBody & "Visit us again soon at <a href=""http://www.mybusiness.com"">"
sMailBody = sMailBody & "http://www.myste.com</a>.<br><br>Sincerely yours,<br><br>David"
sMailBody = sMailBody & "<br>CEO</font></BODY></HTML>"
objMail.TextBody = sMailBody
end if
objMail.Send
Set objMail = Nothing
END SUB
SUB addUser
' Get Registration Fields
newusername = TRIM( Request( "newusername" ) )
newpassword = TRIM( Request( "newpassword" ) )
email = TRIM( Request( "email" ) )
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
html = TRIM( Request( "html" ) )
if html = "Yes" then
html = "1"
else
html = "0"
end if
' Check For Required Fields
backpage = Request.ServerVariables( "SCRIPT_NAME" )
IF newusername = "" THEN
errorForm "You must enter a username.", backpage
END IF
IF newpassword = "" THEN
errorForm "You must enter a password.", backpage
END IF
IF email = "" THEN
errorForm "You must enter your email address.", backpage
END IF
IF street = "" THEN
errorForm "You must enter your street address.", backpage
END IF
IF city = "" THEN
errorForm "You must enter your city.", backpage
END IF
IF state = "" THEN
errorForm "You must enter your state.", backpage
END IF
IF pcode = "" THEN
errorForm "You must enter your post code.", backpage
END IF
IF contact = "" THEN
errorForm "You must enter a contact name.", backpage
END IF
IF store = "" THEN
errorForm "You must enter your store name.", backpage
END IF
IF phone = "" THEN
errorForm "You must enter your phone number.", backpage
END IF
IF fax = "" THEN
errorForm "You must enter your fax number.", backpage
END IF
' Check for Necessary Field Values
IF invalidEmail( email ) THEN
errorForm "You did not enter a valid email address", backpage
END IF
' Check whether username already registered
IF alreadyUser( newusername ) THEN
errorForm "Please choose a different username.", backpage
END IF
' Add New User to Database
sqlString = "INSERT INTO users ( " &_
"user_username, " &_
"user_password, " &_
"user_email, " &_
"user_contact, " &_
"user_store, " &_
"user_phone, " &_
"user_fax, " &_
"user_street, " &_
"user_city, " &_
"user_state, " &_
"user_pcode, " &_
"user_html " &_
") VALUES ( " &_
" '" & fixQuotes( newusername ) & "', " &_
" '" & fixQuotes( newpassword ) & "', " &_
" '" & fixQuotes( email ) & "', " &_
" '" & fixQuotes( contact ) & "', " &_
" '" & fixQuotes( store ) & "', " &_
" '" & fixQuotes( phone ) & "', " &_
" '" & fixQuotes( fax ) & "', " &_
" '" & fixQuotes( street ) & "', " &_
" '" & fixQuotes( city ) & "', " &_
" '" & fixQuotes( state ) & "', " &_
" '" & fixQuotes( pcode ) & "', " &_
" " & html & " " &_
")"
Con.Execute sqlString
' Use the new username and password
username = newusername
password = newpassword
' Add Cookies
addCookie "username", username
addCookie "password", password
END SUB
SUB updateUser
' Get Registration Fields
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
ccnumber = TRIM( Request( "ccnumber") )
cctype = TRIM( Request( "cctype") )
ccexpires = TRIM( Request( "ccexpires") )
ccname = TRIM( Request( "ccname") )
' Check For Required Fields
backpage = "checkout.asp"
IF street = "" THEN
errorForm "You must enter your street address.", backpage
END IF
IF city = "" THEN
errorForm "You must enter your city.", backpage
END IF
IF state = "" THEN
errorForm "You must enter your state.", backpage
END IF
IF pcode = "" THEN
errorForm "You must enter your post code.", backpage
END IF
IF contact = "" THEN
errorForm "You must enter a contact name.", backpage
END IF
IF store = "" THEN
errorForm "You must enter your store name.", backpage
END IF
IF phone = "" THEN
errorForm "You must enter your phone number.", backpage
END IF
IF fax = "" THEN
errorForm "You must enter your fax number.", backpage
END IF
' Update user information in the database
sqlString = "UPDATE users SET " &_
"user_contact='" & fixQuotes( contact ) & "', " &_
"user_store='" & fixQuotes( store ) & "', " &_
"user_phone='" & fixQuotes( phone ) & "', " &_
"user_fax='" & fixQuotes( fax ) & "'," &_
"user_street='" & fixQuotes( street ) & "'," &_
"user_city='" & fixQuotes( city ) & "'," &_
"user_state='" & fixQuotes( state ) & "', " &_
"user_pcode='" & fixQuotes( pcode ) & "'," &_
"user_ccnumber='" & fixQuotes( ccnumber ) & "'," &_
"user_cctype='" & fixQuotes( cctype ) & "'," &_
"user_ccexpires='" & fixQuotes( ccexpires ) & "'," &_
"user_ccname='" & fixQuotes( ccname ) & "' " &_
"WHERE user_id=" & userID
Con.Execute sqlString
END SUB
FUNCTION invalidEmail( email )
IF INSTR( email, "@" ) = 0 OR INSTR( email, "." ) = 0 THEN
invalidEmail = TRUE
ELSE
invalidEmail = FALSE
END IF
END FUNCTION
-------------------------------------------------------------------------
SCRIPT NUMBER 2 - starts here!!!
-------------------------------------------------------------------------
register.asp
<%
newusername = TRIM( Request( "newusername" ) )
newpassword = TRIM( Request( "newpassword" ) )
email = TRIM( Request( "email" ) )
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
ccnumber = TRIM( Request( "ccnumber" ) )
cctype = Request( "cctype" )
ccexpires = TRIM( Request( "ccexpires" ) )
ccname = TRIM( Request( "ccname" ) )
html = TRIM( Request ( "html" ) )
submitpage = Request.ServerVariables( "SCRIPT_NAME" )
%>
<html>
<head><title>Register</title></head>
<body bgcolor="#cfcfff">
<table width="75%" border="0" align="center">
<tr>
<td width="31%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Registration and Login Page</font></td>
</tr>
</table>
<hr>
<table width="500" border="1"
cellpadding=4 cellspacing=0 align="center">
<tr>
<td>
<form method="post" action="<%=submitpage%>">
<div align="left">
<input name="login" type="hidden" value="1">
<input name="pid" type="hidden" value="<%=productID%>">
<font size="2" color="#6699ff" face="Arial"> </font>
<table width="84%" border="0" align="center">
<tr>
<td colspan="3"> <font size="2" color="#6699ff" face="Arial"> <b>LOGIN</b></font></td>
</tr>
<tr>
<td colspan="3"><font size="2" color="#6699ff" face="Arial"></font><font size="2" color="#6699ff" face="Arial">If
you are already a user please enter your username and password:
</font></td>
</tr>
<tr>
<td width="31%"><font size="2" color="#6699ff" face="Arial"><b>username:</b></font></td>
<td width="34%"><font size="2" color="#6699ff" face="Arial">
<input name="username" size="20">
</font></td>
<td width="35%"><font size="2" color="#6699ff" face="Arial">
<input type="submit" value="Login" name="submit">
</font></td>
</tr>
<tr>
<td width="31%"><font size="2" color="#6699ff" face="Arial"><b>password:</b></font></td>
<td width="34%"><font size="2" color="#6699ff" face="Arial">
<input name="password" size="20">
</font></td>
<td width="35%"> </td>
</tr>
</table>
<font size="2" color="#6699ff" face="Arial"></font> </div>
</form>
</td>
</tr>
<tr>
<td bgcolor=""#6699ff">
<div align="left"></div>
</td>
</tr>
<tr>
<td>
<form method="post" action="<%=submitpage%>">
<div align="left">
<input name="register" type="hidden" value="1">
<input name="pid" type="hidden" value="<%=productID%>">
<font size="2" color="#6699ff" face="Arial"> </font>
<table width="91%" border="0" align="center">
<tr>
<td width="97%">
<table width="96%" border="0" align="center">
<tr>
<td colspan="4"> <b><font size="2" color="#6699ff" face="Arial">REGISTER</font></b></td>
</tr>
<tr>
<td colspan="4"><font size="2" color="#6699ff" face="Arial">If
you are not already registered please enter a username &
password: </font></td>
</tr>
<tr>
<td colspan="2"><font size="2" color="#6699ff" face="Arial"><b>username:<br>
</b></font></td>
<td colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="newusername" size=20 maxlength=20 value="<%=Server.HTMLEncode( newusername )%>">
</font><font size="2" color="#6699ff" face="Arial"> </font></td>
</tr>
<tr>
<td colspan="2"><font size="2" color="#6699ff" face="Arial"><b>password:</b></font></td>
<td colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="newpassword" size=20 maxlength=20 value="<%=server.HTMLEncode( newpassword )%>">
</font></td>
</tr>
<tr>
<td height="18" colspan="2"><font size="2" color="#6699ff" face="Arial"><b>email
address:</b></font></td>
<td height="18" colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="email" size=30 maxlength=75 value="<%=Server.HTMLEncode( email )%>">
<br><input name="html" type="checkbox" value="Yes" <% if Server.HTMLEncode( html ) = "Yes" then %>CHECKED<% end if %>>
<b>I can read E-Mail formatted in HTML.</b>
</font>
</font></td>
</tr>
<tr>
<td colspan="4" height="18"><font face="Arial" size="1" color="6699ff">Note:
</font>
<hr>
<font face="Arial" size="2" color="6699ff"><b>Enter your
contact details here:</b></font></td>
</tr>
<tr>
<td width="14%"><b><font face="Arial, Helvetica, sans-serif" color="6699ff" size="2">Contact Name:</font></b></td>
<td colspan="3"><font size="2" color="#6699ff" face="Arial">
<input name="contact" size=50 maxlength=50 value="<%=Server.HTMLEncode( contact )%>">
</font></td>
</tr>
<tr>
<td width="14%"><font color="6699ff" face="Arial, Helvetica, sans-serif" size="2">Store:</font></td>
<td colspan="3"><font size="2" color="#6699ff" face="Arial">
<input name="store" size=50 maxlength=50 value="<%=Server.HTMLEncode( store )%>">
</font></td>
</tr>
<tr>
<td width="14%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Phone:</font></td>
<td width="29%">
<input name="phone" size=20 maxlength=50 value="<%=Server.HTMLEncode( phone )%>">
</td>
<td width="12%"><font color="6699ff" face="Arial, Helvetica, sans-serif" size="2">Fax:</font></td>
<td width="45%">
<input name="fax" size=20 maxlength=50 value="<%=Server.HTMLEncode( fax )%>">
</td>
</tr>
<tr>
<td width="14%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Address:</font></td>
<td colspan="3">
<input name="street" size=50 maxlength=50 value="<%=Server.HTMLEncode( street )%>">
</td>
</tr>
<tr>
<td width="14%"><font color="6699ff" size="2" face="Arial, Helvetica, sans-serif">Town/City</font></td>
<td colspan="3">
<input name="city" size=50 maxlength=50 value="<%=Server.HTMLEncode( city )%>">
</td>
</tr>
<tr>
<td width="14%"><font color="6699ff" size="2" face="Arial">State:</font></td>
<td width="29%">
<input name="state" size=5 maxlength=3 value="<%=Server.HTMLEncode( state )%>">
</td>
<td width="12%"><font size="2" color="#6699ff" face="Arial">Postcode:</font></td>
<td width="45%"><font size="2" color="#6699ff" face="Arial">
<input name="pcode" size=6 maxlength=4 value="<%=Server.HTMLEncode( pcode )%>">
</font></td>
</tr>
<tr>
<td colspan="2"> </td>
<td width="12%"> </td>
<td width="45%"><font size="2" color="#6699ff" face="Arial">
<input type="submit" value="Register" name="submit2">
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</body>
</html>
Need some help please changing a script from CDONTS mail to CDOSYS mail.
Can someone have a look at these two scripts, register.asp and storefuncs.asp and tell me what i am doing wrong. I want to generate an email to customers confirming that they have registered. Everything else in the scripts works fine updating database etc but won't send an email - I don't get an error message either.
Thanks in advance
Rob
storfuncs.asp
<%
'==========================
' Common Functions
'==========================
FUNCTION fixQuotes( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION
SUB addCookie( theName, theValue )
Response.Cookies( theName ) = theValue
Response.Cookies( theName ).Expires = "July 31, 2010"
Response.Cookies( theName ).Path = "/"
Response.Cookies( theName ).Secure = FALSE
END SUB
FUNCTION checkpassword( byVal username, byVal password, byRef Con )
sqlString = "SELECT user_id FROM users " &_
"WHERE user_username='" & username & "' " &_
"AND user_password='" & password & "'"
SET RS = Con.Execute( sqlString )
IF RS.EOF THEN
checkpassword = - 1
ELSE
checkpassword = RS( "user_id" )
addCookie "username", username
addCookie "password", password
END IF
END FUNCTION
FUNCTION SELECTED( firstVal, secondVal )
IF cSTR( firstVal ) = cSTR( secondVal ) THEN
SELECTED = " SELECTED "
ELSE
SELECTED = ""
END IF
END FUNCTION
SUB errorForm( errorMSG, backpage )
%>
<html>
<head><title>Problem</title></head>
<body bgcolor="lightyellow">
<center>
<table width="500" border=1
cellpadding=5 cellspacing=0>
<tr>
<td>
<font face="Arial" size="3" color="darkblue"><b>
There was a problem with the information you entered:
</b></font>
<font size="2" color="red"><b>
<br><%=errorMSG%>
</b></font>
<br>
<form method="post" action="<%=backpage%>">
<input name="error" type="hidden" value="1">
<% formFields %>
<input type="submit" value="Return">
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
<%
Response.End
END SUB
SUB formFields
FOR each item in Request.Form
%>
<input name="<%=item%>" type="hidden"
value="<%=Server.HTMLEncode( Request( item ) )%>">
<%
NEXT
END SUB
'===========================
' Registration Functions
'===========================
SUB sendNewUserMail(sUserName, sUserMail, fHtml)
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
Dim sSql
Dim objMail
Set newMailObj = CreateObject("CDO.Message")
objMailObj.From = "sales@mybusiness.com"
objMailObj.To = sUserMail
objMailObj.Subject = "mybusiness.com.au"
if fHtml = "0" then
objMail.BodyFormat = CdoBodyFormatText
objMail.MailFormat = CdoMailFormatMime
sMailBody = "Dear " & sUserName & "," & vbNewLine & vbNewLine
sMailBody = sMailBody & " Thank you for registering at our site!" & vbNewLine & vbNewLine
sMailBody = sMailBody & " We look forward to serving you in the future. "
sMailBody = sMailBody & "Visit us again soon at http://www.mysite.com." & vbNewLine & vbNewLine
sMailBody = sMailBody & "Sincerely yours," & vbNewLine & vbNewLine
sMailBody = sMailBody & "David," & vbNewLine
sMailBody = sMailBody & "CEO."
objMail.TextBody = sMailBody
else
objMail.TextBodyFormat = CdoBodyFormatHTML
objMail.MailFormat = CdoMailFormatMime
objMail.ContentBase = "http://www.mysite.com.au/"
objMail.ContentLocation = "????"
sMailBody = "<HTML><HEAD><TITLE>Thanks from mycompany.com</TITLE></HEAD>"
sMailBody = sMailBody & "<BODY><table width=""640"" border=""0"" bgcolor=""#ffffff"" cellspacing=""0"" cellpadding=""0"">"
sMailBody = sMailBody & "<tr><td colspan=""2""><hr width=""640""></td></tr></table>"
sMailBody = sMailBody & "<font face=""Arial"" size=""2""><p>Dear " & sUserName & ", "
sMailBody = sMailBody & "<p>Thank you for registering at our site!<p>We look forward to serving you in the future. "
sMailBody = sMailBody & "Visit us again soon at <a href=""http://www.mybusiness.com"">"
sMailBody = sMailBody & "http://www.myste.com</a>.<br><br>Sincerely yours,<br><br>David"
sMailBody = sMailBody & "<br>CEO</font></BODY></HTML>"
objMail.TextBody = sMailBody
end if
objMail.Send
Set objMail = Nothing
END SUB
SUB addUser
' Get Registration Fields
newusername = TRIM( Request( "newusername" ) )
newpassword = TRIM( Request( "newpassword" ) )
email = TRIM( Request( "email" ) )
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
html = TRIM( Request( "html" ) )
if html = "Yes" then
html = "1"
else
html = "0"
end if
' Check For Required Fields
backpage = Request.ServerVariables( "SCRIPT_NAME" )
IF newusername = "" THEN
errorForm "You must enter a username.", backpage
END IF
IF newpassword = "" THEN
errorForm "You must enter a password.", backpage
END IF
IF email = "" THEN
errorForm "You must enter your email address.", backpage
END IF
IF street = "" THEN
errorForm "You must enter your street address.", backpage
END IF
IF city = "" THEN
errorForm "You must enter your city.", backpage
END IF
IF state = "" THEN
errorForm "You must enter your state.", backpage
END IF
IF pcode = "" THEN
errorForm "You must enter your post code.", backpage
END IF
IF contact = "" THEN
errorForm "You must enter a contact name.", backpage
END IF
IF store = "" THEN
errorForm "You must enter your store name.", backpage
END IF
IF phone = "" THEN
errorForm "You must enter your phone number.", backpage
END IF
IF fax = "" THEN
errorForm "You must enter your fax number.", backpage
END IF
' Check for Necessary Field Values
IF invalidEmail( email ) THEN
errorForm "You did not enter a valid email address", backpage
END IF
' Check whether username already registered
IF alreadyUser( newusername ) THEN
errorForm "Please choose a different username.", backpage
END IF
' Add New User to Database
sqlString = "INSERT INTO users ( " &_
"user_username, " &_
"user_password, " &_
"user_email, " &_
"user_contact, " &_
"user_store, " &_
"user_phone, " &_
"user_fax, " &_
"user_street, " &_
"user_city, " &_
"user_state, " &_
"user_pcode, " &_
"user_html " &_
") VALUES ( " &_
" '" & fixQuotes( newusername ) & "', " &_
" '" & fixQuotes( newpassword ) & "', " &_
" '" & fixQuotes( email ) & "', " &_
" '" & fixQuotes( contact ) & "', " &_
" '" & fixQuotes( store ) & "', " &_
" '" & fixQuotes( phone ) & "', " &_
" '" & fixQuotes( fax ) & "', " &_
" '" & fixQuotes( street ) & "', " &_
" '" & fixQuotes( city ) & "', " &_
" '" & fixQuotes( state ) & "', " &_
" '" & fixQuotes( pcode ) & "', " &_
" " & html & " " &_
")"
Con.Execute sqlString
' Use the new username and password
username = newusername
password = newpassword
' Add Cookies
addCookie "username", username
addCookie "password", password
END SUB
SUB updateUser
' Get Registration Fields
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
ccnumber = TRIM( Request( "ccnumber") )
cctype = TRIM( Request( "cctype") )
ccexpires = TRIM( Request( "ccexpires") )
ccname = TRIM( Request( "ccname") )
' Check For Required Fields
backpage = "checkout.asp"
IF street = "" THEN
errorForm "You must enter your street address.", backpage
END IF
IF city = "" THEN
errorForm "You must enter your city.", backpage
END IF
IF state = "" THEN
errorForm "You must enter your state.", backpage
END IF
IF pcode = "" THEN
errorForm "You must enter your post code.", backpage
END IF
IF contact = "" THEN
errorForm "You must enter a contact name.", backpage
END IF
IF store = "" THEN
errorForm "You must enter your store name.", backpage
END IF
IF phone = "" THEN
errorForm "You must enter your phone number.", backpage
END IF
IF fax = "" THEN
errorForm "You must enter your fax number.", backpage
END IF
' Update user information in the database
sqlString = "UPDATE users SET " &_
"user_contact='" & fixQuotes( contact ) & "', " &_
"user_store='" & fixQuotes( store ) & "', " &_
"user_phone='" & fixQuotes( phone ) & "', " &_
"user_fax='" & fixQuotes( fax ) & "'," &_
"user_street='" & fixQuotes( street ) & "'," &_
"user_city='" & fixQuotes( city ) & "'," &_
"user_state='" & fixQuotes( state ) & "', " &_
"user_pcode='" & fixQuotes( pcode ) & "'," &_
"user_ccnumber='" & fixQuotes( ccnumber ) & "'," &_
"user_cctype='" & fixQuotes( cctype ) & "'," &_
"user_ccexpires='" & fixQuotes( ccexpires ) & "'," &_
"user_ccname='" & fixQuotes( ccname ) & "' " &_
"WHERE user_id=" & userID
Con.Execute sqlString
END SUB
FUNCTION invalidEmail( email )
IF INSTR( email, "@" ) = 0 OR INSTR( email, "." ) = 0 THEN
invalidEmail = TRUE
ELSE
invalidEmail = FALSE
END IF
END FUNCTION
-------------------------------------------------------------------------
SCRIPT NUMBER 2 - starts here!!!
-------------------------------------------------------------------------
register.asp
<%
newusername = TRIM( Request( "newusername" ) )
newpassword = TRIM( Request( "newpassword" ) )
email = TRIM( Request( "email" ) )
contact = TRIM( Request( "contact" ) )
store = TRIM( Request( "store" ) )
phone = TRIM( Request( "phone" ) )
fax = TRIM( Request( "fax" ) )
street = TRIM( Request( "street" ) )
city = TRIM( Request( "city" ) )
state = TRIM( Request( "state" ) )
pcode = TRIM( Request( "pcode" ) )
ccnumber = TRIM( Request( "ccnumber" ) )
cctype = Request( "cctype" )
ccexpires = TRIM( Request( "ccexpires" ) )
ccname = TRIM( Request( "ccname" ) )
html = TRIM( Request ( "html" ) )
submitpage = Request.ServerVariables( "SCRIPT_NAME" )
%>
<html>
<head><title>Register</title></head>
<body bgcolor="#cfcfff">
<table width="75%" border="0" align="center">
<tr>
<td width="31%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Registration and Login Page</font></td>
</tr>
</table>
<hr>
<table width="500" border="1"
cellpadding=4 cellspacing=0 align="center">
<tr>
<td>
<form method="post" action="<%=submitpage%>">
<div align="left">
<input name="login" type="hidden" value="1">
<input name="pid" type="hidden" value="<%=productID%>">
<font size="2" color="#6699ff" face="Arial"> </font>
<table width="84%" border="0" align="center">
<tr>
<td colspan="3"> <font size="2" color="#6699ff" face="Arial"> <b>LOGIN</b></font></td>
</tr>
<tr>
<td colspan="3"><font size="2" color="#6699ff" face="Arial"></font><font size="2" color="#6699ff" face="Arial">If
you are already a user please enter your username and password:
</font></td>
</tr>
<tr>
<td width="31%"><font size="2" color="#6699ff" face="Arial"><b>username:</b></font></td>
<td width="34%"><font size="2" color="#6699ff" face="Arial">
<input name="username" size="20">
</font></td>
<td width="35%"><font size="2" color="#6699ff" face="Arial">
<input type="submit" value="Login" name="submit">
</font></td>
</tr>
<tr>
<td width="31%"><font size="2" color="#6699ff" face="Arial"><b>password:</b></font></td>
<td width="34%"><font size="2" color="#6699ff" face="Arial">
<input name="password" size="20">
</font></td>
<td width="35%"> </td>
</tr>
</table>
<font size="2" color="#6699ff" face="Arial"></font> </div>
</form>
</td>
</tr>
<tr>
<td bgcolor=""#6699ff">
<div align="left"></div>
</td>
</tr>
<tr>
<td>
<form method="post" action="<%=submitpage%>">
<div align="left">
<input name="register" type="hidden" value="1">
<input name="pid" type="hidden" value="<%=productID%>">
<font size="2" color="#6699ff" face="Arial"> </font>
<table width="91%" border="0" align="center">
<tr>
<td width="97%">
<table width="96%" border="0" align="center">
<tr>
<td colspan="4"> <b><font size="2" color="#6699ff" face="Arial">REGISTER</font></b></td>
</tr>
<tr>
<td colspan="4"><font size="2" color="#6699ff" face="Arial">If
you are not already registered please enter a username &
password: </font></td>
</tr>
<tr>
<td colspan="2"><font size="2" color="#6699ff" face="Arial"><b>username:<br>
</b></font></td>
<td colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="newusername" size=20 maxlength=20 value="<%=Server.HTMLEncode( newusername )%>">
</font><font size="2" color="#6699ff" face="Arial"> </font></td>
</tr>
<tr>
<td colspan="2"><font size="2" color="#6699ff" face="Arial"><b>password:</b></font></td>
<td colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="newpassword" size=20 maxlength=20 value="<%=server.HTMLEncode( newpassword )%>">
</font></td>
</tr>
<tr>
<td height="18" colspan="2"><font size="2" color="#6699ff" face="Arial"><b>email
address:</b></font></td>
<td height="18" colspan="2"><font size="2" color="#6699ff" face="Arial">
<input name="email" size=30 maxlength=75 value="<%=Server.HTMLEncode( email )%>">
<br><input name="html" type="checkbox" value="Yes" <% if Server.HTMLEncode( html ) = "Yes" then %>CHECKED<% end if %>>
<b>I can read E-Mail formatted in HTML.</b>
</font>
</font></td>
</tr>
<tr>
<td colspan="4" height="18"><font face="Arial" size="1" color="6699ff">Note:
</font>
<hr>
<font face="Arial" size="2" color="6699ff"><b>Enter your
contact details here:</b></font></td>
</tr>
<tr>
<td width="14%"><b><font face="Arial, Helvetica, sans-serif" color="6699ff" size="2">Contact Name:</font></b></td>
<td colspan="3"><font size="2" color="#6699ff" face="Arial">
<input name="contact" size=50 maxlength=50 value="<%=Server.HTMLEncode( contact )%>">
</font></td>
</tr>
<tr>
<td width="14%"><font color="6699ff" face="Arial, Helvetica, sans-serif" size="2">Store:</font></td>
<td colspan="3"><font size="2" color="#6699ff" face="Arial">
<input name="store" size=50 maxlength=50 value="<%=Server.HTMLEncode( store )%>">
</font></td>
</tr>
<tr>
<td width="14%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Phone:</font></td>
<td width="29%">
<input name="phone" size=20 maxlength=50 value="<%=Server.HTMLEncode( phone )%>">
</td>
<td width="12%"><font color="6699ff" face="Arial, Helvetica, sans-serif" size="2">Fax:</font></td>
<td width="45%">
<input name="fax" size=20 maxlength=50 value="<%=Server.HTMLEncode( fax )%>">
</td>
</tr>
<tr>
<td width="14%"><font face="Arial, Helvetica, sans-serif" size="2" color="6699ff">Address:</font></td>
<td colspan="3">
<input name="street" size=50 maxlength=50 value="<%=Server.HTMLEncode( street )%>">
</td>
</tr>
<tr>
<td width="14%"><font color="6699ff" size="2" face="Arial, Helvetica, sans-serif">Town/City</font></td>
<td colspan="3">
<input name="city" size=50 maxlength=50 value="<%=Server.HTMLEncode( city )%>">
</td>
</tr>
<tr>
<td width="14%"><font color="6699ff" size="2" face="Arial">State:</font></td>
<td width="29%">
<input name="state" size=5 maxlength=3 value="<%=Server.HTMLEncode( state )%>">
</td>
<td width="12%"><font size="2" color="#6699ff" face="Arial">Postcode:</font></td>
<td width="45%"><font size="2" color="#6699ff" face="Arial">
<input name="pcode" size=6 maxlength=4 value="<%=Server.HTMLEncode( pcode )%>">
</font></td>
</tr>
<tr>
<td colspan="2"> </td>
<td width="12%"> </td>
<td width="45%"><font size="2" color="#6699ff" face="Arial">
<input type="submit" value="Register" name="submit2">
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</body>
</html>