Forum Moderators: open
<%
'Save entered username and password
Username = Request.Form("txtUsername")
Password = Request.Form("txtPassword")
Fullname = Request.Form("txtFullname")
'Check if username and password are entered
if Username = "" then Response.redirect("login.asp?login=createnamefailed")
if Password = "" then Response.Redirect("login.asp?login=createpassfailed")
'Build connection
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("guestbook.mdb")
set rs = server.CreateObject ("ADODB.Recordset")
'Open all records
rs.Open "SELECT * FROM userlist", conn, 3, 3
'Check if username doesn't already exist
do while not rs.EOF
if rs("username")=Username then
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=createnamefailed")
end if
rs.MoveNext
loop
'Add a record
rs.AddUser
'Put username and password in record
rs("username")=Username
rs("password")=Password
rs("fullname")=Fullname
'Save record
rs.Update
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=creatednew")
%>
However, during my trial, there is an error. It goes like this:
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'rs.AddUser'
/vdo/create.asp, line 29
(vdo is the file name and create.asp is the document name)
Can you guys tell me what went wrong? It'll help a lot for my project.
I believe that instead of calling "AddUser", you should call "AddNew".
Here is an example. [msdn.microsoft.com]
The rest of your code looks great.
One thing I would suggest is to call Trim on your form values.
For Example:
Username = Trim(Request.Form("txtUsername")&"") This will ensure that you always get at minimum an empty string and never a null or anything else. Also if you standardize this when inserting into the database, extra spaces won't make the usernames/passwords/etc different.
-=casey=-
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/vdo/create.asp, line 29
Is there anything i can do because I do not know how to do it...
Anyway, thanks CaseyRyan...
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/vdo/create.asp, line 29
Is there anything i can do because I do not know how to do it...
Anyway, thanks CaseyRyan...