Script Problem?

 
Post new topic   Reply to topic    Aprelium Forum Index -> Classic ASP
View previous topic :: View next topic  
Author Message
HIWD
-


Joined: 13 Apr 2004
Posts: 142
Location: Dublin, Ireland

PostPosted: Thu Aug 05, 2004 9:46 pm    Post subject: Script Problem? Reply with quote

Can anyone please tell me what is wrong with is script. This script is used for a user registration page, when the user fills in fields and clicks submit it sends then an email and then puts the info into a ms access database. But the problem is, its sending the email, but its not inserting into the database. Any ideas?

Code:
<%
' Validate: Email

Function check_email(Email, isOpt)

 Dim regEx, retVal

 check_email = false

 If ( (Len(Email) = 0) and (isOpt = true) ) Then

  check_email = true

 Else
 
  Set regEx = New RegExp
  regEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
  regEx.IgnoreCase = true

  retVal = regEx.Test(Email)

  If retVal Then
   check_email = true
  End If

 End If

End Function

'----------
' Validate: Equal to field

Function check_equalto(original, repeated)

 check_equalto = false

 If (original = repeated) Then
  check_equalto = true
 End If

End Function

Dim aspEMail
Set aspEMail = Server.CreateObject("Persits.MailSender")
Dim aspEMailConf
Set aspEMailConf = Server.CreateObject("Persits.MailSender")

Name = request.form("Name")
Email = request.form("Email")
Username = request.form("Username")
pass1 = request.form("pass1")
pass2 = request.form("pass2")
Submit = request.form("Submit")

' Field Validations

validationFailed = false

if ( (not check_email(Email, false))) then
 validationFailed = true
End if

if ( (not check_equalto(pass1, pass2))) then
 validationFailed = true
End if

' Redirect user to the error page

if (validationFailed = true) then

 Response.Redirect "host_error.asp"

Else

' Confirmation Email: aspEmail

 confEmailTo = Email
 confEmailFrom = "info@hiwd-dev.com"
 confEmailSubject = "Thank you for registering!"
 confEmailBodyText = "Thank you for registering, " & Name & "." & vbCrLf _
 & "Below is your login details." & vbCrLf _
 & "" & vbCrLf _
 & "Username: " & Username & "" & vbCrLf _
 & "Password: " & pass1 & "" & vbCrLf _
 & "" & vbCrLf _
 & ""

 aspEmailConf.Host = "mail.computerclubhouse.ie"
 aspEmailConf.From = confEmailFrom
 aspEMailConf.AddAddress confEmailTo
 aspEmailConf.Subject = confEmailSubject
 aspEmailConf.Body = confEmailBodyText
 aspEmailConf.Charset = "ISO-8859-1"
 aspEmailConf.ContentTransferEncoding = "quoted-printable"

 On Error Resume Next

 aspEmailConf.Send
 
 If Err <> 0 then
  Response.Write "aspEmail reported an error sending the email. Error: " & Err.Description
 End If

 ' Dump field values to a MSAccess database

 set conn = Server.CreateObject("ADODB.Connection")
 conn.Provider = "Microsoft.Jet.OLEDB.4.0"
 conn.Open "db/main_db.mdb; PWD=abc123"
 


 sqlcmd = "INSERT INTO users(Name, Email, Username, Password) VALUES('" & Name & "', '" & Email & "', '" & Username & "', '" & pass1 & "')"

 on error resume next

 conn.Execute sqlcmd,recaffected

 if err<>0 then
  Response.Write("Could not write to DB!")
 end if

' Redirect user to success page

 Response.Redirect "login.asp"

End if

' End of ASP script
%>
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Aug 06, 2004 1:18 am    Post subject: Re: Script Problem? Reply with quote

HIWD,

Try adding a better error reporting (after if err<>0) to get more information from ASP about the problem. Without this, you can't guess what the exact DB error is.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
HIWD
-


Joined: 13 Apr 2004
Posts: 142
Location: Dublin, Ireland

PostPosted: Fri Aug 06, 2004 1:49 pm    Post subject: Reply with quote

Thank you aprelium, I done what you said, and I found the source of my problem.
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Classic ASP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group