Ive been working on a simple data base on my IIS and have created a funtional login system. However when I went to create a sign up site for my page I keep getting errors. This is my text. All errors end up around were im attempting to edit it and add a new user.
Text:
<% option explicit %>
<% if request.form(“user”)=“” and request.form(“pass1”)=“” and request.form(“pass2”)=“” and request.form(“email”)=“” or request.form(“pass1”)<>request.form(“pass2”) then %>
<% a=a+1 %>
Sign Up
<% if a<>1 then%>Error: You did not fill in all of the form properly. <%else%>
It is very easy to sign up to our secure server so that you can test you asp scripts.
Just fill out the form below and you will be one step closer to becoming a testing site member.
User Name:
Password:
Verify Password:
Email:
Hummm…
I have been modleing my script after ASP for Dummies and that is they way that they make the connection. I have used this other times and it has worked so I dont think that is the problem.
You may use this example I made as a pattern. Just add the necessary client-side and server-side validation scripts, as well as modify filenames and the like:
(registration-form.html)
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Registration Form</title>
<script type="text/javascript">
<!--
function checkregistrationform() {
if (document.getElementById("uidbox").value == "") {
alert("Please provide a user ID.")
document.getElementById("uidbox").focus()
return false
} else if (document.getElementById("pwdbox").value == "") {
alert("Please provide a password.")
document.getElementById("pwdbox").focus()
return false
} else {
return true
}
}
//-->
</script>
</head>
<body>
<form action="registration-script.asp" method="POST" onsubmit="return checkregistrationform();">
<div>User ID: <input type="text" size="20" maxlength="20" id="uidbox" /></div>
<div>Password: <input type="password" size="20" maxlength="20" id="pwdbox" /></div>
<div><input type="submit" value="Create Account" /></div>
</form>
</body>
</html>
(registration-script.asp)
<% @Language="VBScript" %>
<% Option Explicit %>
<%
On Error Resume Next
Dim CN, RS
Dim CNstr
Dim DBrelpath
Dim uidval, pwdval
Dim haserror, uidexists
'RETRIEVE FORM DATA
If Trim(Request.Form("uidbox")) <> "" And Trim(Request.Form("pwdbox")) <> "" Then
uidval = Replace(Replace(Request.Form("uidbox"),"'",""), """", "")
pwdval = Replace(Replace(Request.Form("pwdbox"),"'",""), """", "")
Else
Response.Redirect("registration-form.html")
End If
'INITIALIZE VARIABLES
haserror = False
DBrelpath = "yourdb.mdb"
'CREATE INSTANCE OF ADODB.CONNECTION
Set CN = Server.CreateObject("ADODB.Connection")
'USE LINE BELOW IF USING A DSN
'CN.ConnectionString = "DSN=yourdsn;"
'USE LINE BELOW IF NOT USING DSN
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DBrelpath) & ";"
'OPEN CONNECTION
CN.Open
'CHECK FOR ERROR
If Err.Number <> 0 Then
Set CN = Nothing
Response.Redirect("servererror.html")
End If
'CREATE INSTANCE OF ADODB.RECORDSET
Set RS = Server.CreateObject("ADODB.RecordSet")
'DEFINE PROPERTIES AND CALL METHODS OF RECORDSET
With RS
'SERVER-SIDE CURSORS
.CursorLocation = 2
'OPTIMISTIC LOCKING
.LockType = 3
'DEFINE CONNECTION TO USE
Set .ActiveConnection = CN
'ASSOCIATE TABLE TO RECORDSET
.Source = "Users"
'OPEN RECORDSET
.Open()
'CHECK FOR ERROR
If Err.Number <> 0 Then
haserror = True
Else
'ATTEMPT TO FIND THE SELECTED UID
.Find "uid='" & uidval & "'"
'CHECK IF UID INDEED EXISTS
If Not .EOF Then
uidexists = True
Else
'CREATE NEW ROW
.AddNew()
'DEFINE FIELD VALUES
.Fields("uid") = uidval
.Fields("pwd") = pwdval
'WRITE CHANGES
.Update()
'CHECK FOR ERROR
If Err.Number <> 0 Then
haserror = True
End If
End If
'CLOSE RECORDSET
.Close()
End If
End With
'DESTROY OBJECT
Set RS = Nothing
'CLOSE CONNECTION
CN.Close()
'DESTROY OBJECT
Set CN = Nothing
'CHECK IF UID EXISTS
If uidexists Then
Response.Redirect("chooseanotheruid.html")
End If
'CHECK FOR ERROR
If haserror Then
Response.Redirect("servererror.html")
End If
'REGISTRATION SUCCESSFUL
Response.Redirect("registration-successful.asp")
%>
By the way, I assumed that you are using a Microsoft Access Database. Obviously, the script would have been a lot better (like allow ’ and " in the password and other fields) if you:
[ul]
[li]have pre-built queries in MS Access that can accept parameters to perform registration routines, or
[/li][li]used MS SQL Server 2000 and created stored procedures in it
[/li][/ul]
i think i deleted the page because i didnt think anyone was going to respond to my post. well ill just have to base it off some other script. thanks though.