Forums
This topic is locked
If user exists
Posted 20 Jun 2002 01:30:01
1
has voted
20 Jun 2002 01:30:01 James Smith posted:
hey ive designed a registration page, but i want to know how to make it check if a user exists or not and if a user does then go to a different page. how can i do this. the code of my page is bellow <%@LANGUAGE="VBSCRIPT"%>
<%
set oConn = Server.CreateObject("ADODB.Connection"
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\goftr\db\members2000.mdb")
%>
<%
Dim rsCheckDuplicates__strUserID
rsCheckDuplicates__strUserID = "xyz"
if (Request.Form("loginanme" <> "" then rsCheckDuplicates__strUserID = Request.Form("loginanme"
%>
<%
set rsCheckDuplicates = Server.CreateObject("ADODB.Recordset"
rsCheckDuplicates.ActiveConnection = oConn
rsCheckDuplicates.Source = "SELECT * FROM tblUser WHERE loginname = '" + Replace(rsCheckDuplicates__strUserID, "'", "''" + "'"
rsCheckDuplicates.CursorType = 0
rsCheckDuplicates.CursorLocation = 2
rsCheckDuplicates.LockType = 3
rsCheckDuplicates.Open()
rsCheckDuplicates_numRows = 0
%>
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
MM_editConnection = oConn
MM_editTable = "tblUser"
MM_editRedirectUrl = ""
MM_fieldsStr = "loginname|value|password|value|affiliation|value"
MM_columnsStr = "loginname|',none,''|password|',none,''|affiliation|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
if not rsCheckDuplicates.EOF then
response.redirect ("register.asp"
else
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert") <> "" Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
end if
%>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; ch****t=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p align="center"><i><font face="Arial, Helvetica, sans-serif" size="+2">Welocme
to the Golden age of the Republic</font></i></p>
<hr>
<p align="left"> </p>
<div align="center">
<p>To gain full acces to our site you will need to register. No personal information
will be collected abd your login information</p>
<p>will simply be used to ensure that only registered memebrs use our services.
Thank you. To reset the form at any time press</p>
<p>the reset button located at the bottom.</p>
<p> </p>
<hr>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<div align="left">
<p>User Name
<input type="text" name="loginname">
*</p>
<p>Password
<input type="password" name="password">
*</p>
<p>Affiliation
<select name="affiliation">
<option value="Sith">Sith</option>
<option value="Republic">Republic</option>
</select>
*</p>
<p>* denotes a required field</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p>
<input type="reset" name="reset" value="Reset">
</p>
</div>
<input type="hidden" name="MM_insert" value="true">
</form>
<p align="left"> </p>
</div>
</body>
</html>
<%
rsCheckDuplicates.Close()
%>
Replies
Replied 20 Jun 2002 18:38:49
20 Jun 2002 18:38:49 Andrew Watson replied:
There is a redirect if user exists extension...
:: Son, im Thirty.... ::
:: Son, im Thirty.... ::
Replied 20 Jun 2002 19:00:26
20 Jun 2002 19:00:26 James Smith replied:
any idea what its called