Varun Jain schreef:
[quoted text, click to view] > hi,
> i was creating an asp page that is supposed to add some registration data to
> a database. however, it is not adding to the database nor is it giving any
> errors. this is really wierd. although, it is reading from the database.
>
> i have attached the code for three files below
> Register.asp
> AddUser.asp
> V2E2Connection.asp
>
> Register.asp:
> ---------------------------
> <HTML>
> <HEAD>
>
> <SCRIPT language="JavaScript">
> <!--
> function VerifyData()
> {
> if (document.frmUser.strPassword.value !=
> document.frmUser.strVerifyPassword.value)
> {
> alert ("Your passwords do not match - please reenter");
> return false;
> }
> else
> return true;
> }
> -->
> </SCRIPT>
>
>
>
> <%Session("blnValidUser")=True%>
> <TITLE>Registration page</TITLE>
> </HEAD>
>
> <BODY>
>
> <H1>Register to V2E2</H1>
> <FORM ACTION="AddUser.asp" NAME="frmUser" METHOD="POST" onSubmit="return
> VerifyData()">
> <P>Username: <INPUT TYPE="TEXT" NAME="strUserName"></P>
> <P>Password: <INPUT TYPE="Password" Name="strPassword"></P>
> <P>Verify Password: <INPUT TYPE="Password"
> Name="strVerifyPassword"></P><BR>
> <P>First Name: <INPUT TYPE="TEXT" Name="strFirstName"></P>
> <P>Family Name: <INPUT TYPE="TEXT" Name="strFamilyName"></P><BR>
> <P>Age: <INPUT TYPE="TEXT" NAME="intAge"></P>
> <P>Gender: <INPUT TYPE="TEXT" NAME="strGender"></P>
> <P>Course: <INPUT TYPE="TEXT" NAME="strCourse"></P>
>
> <BR><INPUT TYPE="SUBMIT" VALUE="Register">
>
> <BR><A HREF="index.asp">Return to home page</A>
>
> </BODY>
> </HTML>
> -----------------------------------
>
>
> AddUser.asp
> ----------------------------------
> <!--#include file="V2E2Connection.asp"-->
> <%
> Dim rsUsers
> Set rsUsers = Server.CreateObject("ADODB.RecordSet")
> rsUsers.Open "tblPerson", objConn, adOpenForwardOnly,
> adLockBatchOptimistic, adCmdTable
>
> If Session("strUserName") <> "" Then
> rsUsers.Filter = "strUserName = '" & Request.Form("strUserName") & "'" & _
> "AND strPassword = '" & Request.Form("strPassword") & "'"
> If rsUsers.EOF Then
> rsUsers.AddNew 'Else username/password match
> End If
> End If
>
> 'Add Record data...
> rsUsers("strUserName") = Request.Form("strUserName")
> rsUsers("strPassword") = Request.Form("strPassword")
> rsUsers("strFirstName") = Request.Form("strFirstName")
> rsUsers("strFamilyName") = Request.Form("strFamilyName")
> rsUsers("strGender") = Request.Form("strGender")
> rsUsers("intAge") = Request.Form("intAge")
> rsUsers("strCourse") = Request.Form("strCourse")
>
> rsUsers.Update
>
> Dim strName, strValue 'populate the session variables to correspond to
> data in database
> For each strField in rsUsers.Fields
> strName = strField.Name
> strValue = strField.Value
> Session(strName) = strValue
> Next
>
> Session("blnValidUser") = True 'login the user automatically
> Response.Redirect "RegisteredIndex.asp" 'redirect to registered users
> homepage
> %>
> ---------------------------------
>
>
> V2E2Connection.asp
> ---------------------------------
> <!-- METADATA TYPE="typelib"
> FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
> <%
> 'The following code is to be used as a SSI. It has all the data access
> connection information.
> 'It declares a value to hold the database connection and then opens it.
> 'It also retrieves the current users PersonID from the database, so that it
> can be used throughout the session
>
> 'Initialising the connection object
> Dim objConn
> Set objConn = Server.CreateObject("ADODB.Connection")
> objCOnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
> "Data Source= c:\datastores\v2e2.mdb"
>
> 'Checking if user is valid and if the PersonID parameter is set.
> 'If valid user and no personId, then creates a recordset object to get the
> personID from the database
>
> If Session("blnVaildUser") = True Then
>
> Dim rsUserNameCheck
> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
> Dim strSQL
> strSQL = "SELECT * FROM tblPerson " & _
> "WHERE strUserName = '" & Session("strUserName") & "';"
> rsUserNameCheck.Open strSQL, objConn
>
>
> If rsUserNameCheck.EOF Then 'If username is not present in the table
> then, invalidate the user and log him out"
> Session("blnValidUser") = False
> End If
> rsUserNameCheck.Close
> Set rsUserNameCheck = Nothing
> End If
> %>
> -------------------------------------------
>
>
HI,
Do you have write permission for the directory the database is stored.
Reminder; write permission should be set for the webserver user.