Advertisement

09.23.2005 at 12:58PM PDT, ID: 21572314
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Form Validation

Asked by wirthr in Active Server Pages (ASP)

Tags: ,

Here is my code, which returns:


Microsoft VBScript compilation  error '800a03f6'

Expected 'End'

/content/postnewuser.asp, line 82





<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include virtual="/Connections/gratisconn.asp" -->
<%
'Always include the above file adovbs.inc. look up what is in there to understand why.
Dim strSQL, rsData, strFirstName, strLastName, strBirthdate, strCity_State, strTelephone, strEmail, strPassword

'We first collect the data from the form collection using the request method. We collect these fisrt into a variable so as we can validate if you need to do so. They can be collected and put straight into the database, but for now this way we can show clearly what is happening.

strFirstName = Request.Form("firstname")
strLastName = Request.Form("lastname")
strBirthdate = trim(Request.Form("dob"))
strCity_State = trim(Request.Form("address"))
strTelephone = Request.Form("telephone")
strEmail = trim(Request.Form("email"))
strPassword = trim(Request.Form("password"))


set rsData = Server.CreateObject("ADODB.Recordset")

'You need to amend the deatils below for your SQL server. This is a dsnless connection.
strSQL = "SELECT * FROM gratis_items WHERE gratis_items.email = '" & strEmail & "'"

rsData.Source = strSQL
rsData.CursorType = 2 'There a several cursor types, choose one which will let you do what you need to to the database. Look up cursor types and understand them.
rsData.LockType = 2 'Do you need exclusive use of the database? Look these up too and understand them
rsData.Open strSQL, conn ' Open database
%>
<%
Validated_Form = true

IF len(strEmail)<6 OR InStr(Form_Email,"@")=0 THEN
      Validated_Form = false
END IF

IF len(strtelephone)<10 THEN
      Validated_Form = false
END IF

IF len(strpassword)<6 THEN
      Validated_Form = false
END IF
IF NOT Validated_Form THEN
%>
<HTML>
<BODY>
Error, please click your browser's back button and check your information.  Email address must contain the @ symbol, your telephone number must be in the format of xxx-xxx-xxxx, and your password must be at least 6 characters.  Please double check that all of these conditions are true.
</BODY>
</HTML>
<%
ELSE
%>
<%
If rsData.EOF Then ' If there is no records which fit he above SELECT criteria, then the email address must be a new one! So go ahead and create a new record.
     
         
              rsData.AddNew ' Create a new record
          rsData("firstname") = strFirstName
          rsData("lastname") = strLastName
          rsData("dob") = strBirthdate
          rsData("address") = strCity_State
          rsData("telephone") = strTelephone
          rsData("email") = strEmail
          rsData("password") = strPassword
              session("emailaddy") = strEmail
              session("password") = password
     
      
               rsData.Update
          rsData.Close ' Close the data connection
          Set rsData = Nothing ' Always release the object to clean up the server

          Response.redirect "../members/login.asp" ' A successful registration, send user to congrats page.
Else ' The email address has already been registered. Tell the user and send them back - Nothing has been saved to the database
%>

<SCRIPT language = "Javascript">
     alert("Sorry, that email address exists in our system, please choose another");
     window.history.back();
</SCRIPT>
<%
End If
%>Start Free Trial
[+][-]09.23.2005 at 01:13PM PDT, ID: 14947939

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: form, page
Sign Up Now!
Solution Provided By: kmorris1186
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.23.2005 at 01:20PM PDT, ID: 14948005

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.23.2005 at 01:32PM PDT, ID: 14948102

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43