|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
pls help me, i am novice in asp
<%
Option Explicit Dim strError, strSQL 'see if the form has been submitted 'If Request.Form("action")="register" Then 'the form has been submitted '// validate the form 'check if a username has been entered If Request.Form("username") = "" Then strError = strError & "Please enter a username<br> "& vbNewLine response.Write(strError) 'end if 'check if a password has been entered elseif Request.Form("password") = "" Then strError = strError & " Please enter a password<br>" & vbNewLine response.Write(strError) 'check if the passwords are the same... but don't display it if the password field is blank. elseif Request.Form("password") <> Request.Form("password_confirm")_ And Request.Form("password") <> "" Then strError = strError & "- Your passwords do not match<br>" & vbNewLine response.Write(strError) end if '// check if an error has occured If strError = "" Then 'continue 'include database connection code %> <!--#include file="sqlconnection.asp"--> <% ' On Error Resume Next '// check for an error '// ATTENTION: this should be changed depending on the database provider ' If Err.Number = -2147217900 Then strError = "- That username is already in use. Please choose another<br>" & vbNewLine response.Write(strError) Else If Err.Number <> 0 Then strError = "- An error occured. " & Err.Number & " : " & _ Err.Description & "<br>" & vbNewLine 'record created... redirect '// create the SQL Else Response.Write "Your user name and password has been accepted." strSQL = "INSERT INTO members ([username],[password]) VALUES " & _ "('" & Request.Form("username") & "','" & _ Request.Form("password") & "')" '// run the SQL objConn.Execute strSQL Response.Redirect "login.asp?msg=" & Server.URLEncode("Thank you for registering") Response.End End If 'restore standard error handling On Error Goto 0 End If If strError <> "" Then 'output the error message 'add extra HTML... strError = "<p><font color=""#FF0000"">The following errors occured:" & _ "</font><br>" & vbNewLine & strError End If End If 'End If 'Function fixQuotes(strData) ' fixQuotes = Replace(strData,"'","''") 'End Function %> here is my code for registration form... help me about how to check izzit the username exist in database or not... pls give me the code that can solve my problem... thanks alot |
|
#2
|
||||
|
||||
|
Code:
sql_checkname = "SELECT * FROM members WHERE username='" & request.form("username") & "'"
SET checkname = objConn.execute(sql_checkname)
if not checkname.EOF then
' the username already exists
else
' the username doesn't already exist
end if
|
|
#3
|
|||
|
|||
|
thank
thank you , i can do it already from ur help...
|
|
#4
|
||||
|
||||
|
great! Glad I could help
![]() |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > pls help me, i am novice in asp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|