|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Weird Access Database problem
Hi all,
This is my first post. I have a strange problem...I have created registration page for my site, which when submitted stores the user info in an access database stored on the server. I can then login with the given user details fine, but if i shut the explorer winbdow and come out of the site for about 30 mins+, the database loses all of the information....Any ideas why? Many Thanks, A stressed out Steve |
|
#2
|
||||
|
||||
|
HI Steve,
welcome to the forum ![]() Well the session variables expire after about 20 mins by default, have you had a look in the database, and there is now values in the database itself? Can you post the code where you insert the values into the database and where the user logs in?
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
|||
|
|||
|
Thanks for the warm welcome and the reply...
Here is the registration asp code... <% ' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit. On Error Resume Next Session("FP_OldCodePage") = Session.CodePage Session("FP_OldLCID") = Session.LCID Session.CodePage = 1252 Session.LCID = 1033 Err.Clear strErrorUrl = "http://www.xxxxxxxxxxxxxxxxx.co.uk/reg_error.asp" If Request.ServerVariables("REQUEST_METHOD") = "POST" Then If Request.Form("VTI-GROUP") = "0" Then Err.Clear Set fp_conn = Server.CreateObject("ADODB.Connection") FP_DumpError strErrorUrl, "Cannot create connection" Set fp_rs = Server.CreateObject("ADODB.Recordset") FP_DumpError strErrorUrl, "Cannot create record set" fp_conn.Open Application("registration_ConnectionString") FP_DumpError strErrorUrl, "Cannot open database" fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable FP_DumpError strErrorUrl, "Cannot open record set" fp_rs.AddNew FP_DumpError strErrorUrl, "Cannot add new record set to the database" Dim arFormFields0(15) Dim arFormDBFields0(15) Dim arFormValues0(15) arFormFields0(0) = "title" arFormDBFields0(0) = "title" arFormValues0(0) = Request("title") arFormFields0(1) = "Street" arFormDBFields0(1) = "Street" arFormValues0(1) = Request("Street") arFormFields0(2) = "username" arFormDBFields0(2) = "username" arFormValues0(2) = Request("username") arFormFields0(3) = "MobilePhone" arFormDBFields0(3) = "MobilePhone" arFormValues0(3) = Request("MobilePhone") arFormFields0(4) = "County" arFormDBFields0(4) = "County" arFormValues0(4) = Request("County") arFormFields0(5) = "City" arFormDBFields0(5) = "City" arFormValues0(5) = Request("City") arFormFields0(6) = "Email" arFormDBFields0(6) = "Email" arFormValues0(6) = Request("Email") arFormFields0(7) = "singlestatus" arFormDBFields0(7) = "singlestatus" arFormValues0(7) = Request("singlestatus") arFormFields0(8) = "contactinfo_Address2" arFormDBFields0(8) = "contactinfo_Address2" arFormValues0(8) = Request("contactinfo_Address2") arFormFields0(9) = "Name" arFormDBFields0(9) = "Name" arFormValues0(9) = Request("Name") arFormFields0(10) = "homePhone" arFormDBFields0(10) = "homePhone" arFormValues0(10) = Request("homePhone") arFormFields0(11) = "password" arFormDBFields0(11) = "password" arFormValues0(11) = Request("password") arFormFields0(12) = "Interests" arFormDBFields0(12) = "Interests" arFormValues0(12) = Request("Interests") arFormFields0(13) = "Postcode" arFormDBFields0(13) = "Postcode" arFormValues0(13) = Request("Postcode") arFormFields0(14) = "Nationality" arFormDBFields0(14) = "Nationality" arFormValues0(14) = Request("Nationality") FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0 If Request.ServerVariables("REMOTE_HOST") <> "" Then FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"), "Remote_computer_name" End If If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"), "Browser_type" End If FP_SaveFieldToDB fp_rs, Now, "Timestamp" If Request.ServerVariables("REMOTE_USER") <> "" Then FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_USER"), "User_name" End If fp_rs.Update FP_DumpError strErrorUrl, "Cannot update the database" fp_rs.Close fp_conn.Close Session("FP_SavedFields")=arFormFields0 Session("FP_SavedValues")=arFormValues0 Session.CodePage = Session("FP_OldCodePage") Session.LCID = Session("FP_OldLCID") Response.Redirect "http://www.xxxxxxxx.co.uk/reg_success.asp" End If End If Session.CodePage = Session("FP_OldCodePage") Session.LCID = Session("FP_OldLCID") %> ============================================= Here is the login page... <% Option Explicit Dim strError, strSQL, objRS 'see if the form has been submitted If Request.Form("action")="login" 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 'check if a password has been entered If Request.Form("password") = "" Then _ strError = strError & "- Please enter a password<br>" & vbNewLine '// check if an error has occured If strError = "" Then 'continue 'include database connection code %> <!--#include file="admin/inc-dbconnectionreg.asp"--> <% '// create the SQL strSQL = "SELECT id,password FROM Results WHERE username='" & _ fixQuotes(Request.Form("username")) & "'" '// run the SQL Set objRS = objConn.Execute (strSQL) '// see if there are any records returned If objRS.EOF Then 'no username found strError = "- Invalid username or password<br>" & vbNewLine Else 'check password If objRS("password")=Request.Form("password") Then 'username/password valid 'save session data Session("loggedin") = True Session("userid") = objRS("id") 'redirect to Administration area Response.Redirect ("index.html") Response.End Else 'invalid password strError = "- Invalid username or password<br>" & vbNewLine End If End If End If If strError <> "" Then 'output the error message 'add extra HTML... strError = "<p><font color=""#FF0000""><center>The following errors occured:" & _ "</font><br>" & vbNewLine & strError End If 'display message in URL.. (ie thank you for registering) If Request.QueryString("msg") <> "" And strError = "" Then strError = "<p>" & Request.QueryString("msg") & "</p>" End If End If Function fixQuotes(strData) fixQuotes = Replace(strData,"'","''") End Function're-set session data Session("loggedin")="" Session("userid")="" %> <html> <head> <base target="_parent"> </head> <body topmargin="0" leftmargin="0"> <h1 align="center"><font face="Monotype Corsiva"> <span style="font-weight: 400; text-decoration: underline">Clients Area Login</span></font></h1> <p align="center"><font size="4" face="Monotype Corsiva">Please enter your username and password to access the Clients Area.</font></p> <%=strError%> <form action="--WEBBOT-SELF--" method="POST"> <input type="hidden" name="action" value="login"> <table border="0" width="226" align="center"> <tr> <td width="68" align="center"> <p align="center"><b>Username</b></td> <td width="150" align="center"> <p align="center"> <input type="text" maxlength=20 name="username" value="<%=Server.HTMLEncode(Request.Form("username"))%>" size="20"></td> </tr> <tr> <td width="68" align="center"> <p align="center"><b>Password</b></td> <td width="150" align="center"> <p align="center"> <input type="password" maxlength=20 name="password" value="<%=Server.HTMLEncode(Request.Form("password"))%>" size="20"></td> </tr> <tr> <td width="68" align="center"> <p align="center"> </td> <td width="150" align="center"> <p align="center"><input type="submit" value="Login"> <br> <font face="Monotype Corsiva" size="4"> <a target="_self" href="forgot_pass.asp">Forgotten Password?</a></font></td> </tr> </table> </form> </body> </html> Thanks a lot, Steve |
|
#4
|
|||
|
|||
|
cont...
Just to confirm that there is no info in database...it's like it erases itself when i'm not looking!
![]() |
|
#5
|
||||
|
||||
|
Thats really weird, is the values deleted from the database after 30 minutes or do you have to log in again after 30 minutes?
If the values a physically deleted from the database, post the code for this function FP_SaveFormFields take it this saves to the db? |
|
#6
|
|||
|
|||
|
Quote:
Everything just seems to get deleted from db.....if you try to login with the information you created the account with, it says not found...I checked the db and all records have disappeared. Here are the ssave database function....i didn't make themn, they are the frontpage ones, as i'm new to asp! Function FP_SaveFormFields(rs, rgFormFields, rgDBFields) On Error Resume Next Err.Clear Dim i For i = 0 To UBound(rgFormFields) FP_SaveFormField rs, rgFormFields(i), rgDBFields(i) Next Err.Clear End Function Function FP_SaveFormField(rs, strField, strDBField) On Error Resume Next Err.Clear If (Request.Form(strField)) = "" And rs(strDBField).Type <> adBoolean Then Exit Function End If FP_SaveFieldToDB rs, Request.Form(strField), strDBField Err.Clear End Function Function FP_SaveFieldToDB(rs, strField, strDBField) On Error Resume Next Err.Clear Dim fp_Debug fp_Debug = False Select Case rs(strDBField).Type Case adInteger Or adBigInt Or adUnsignedTinyInt Or adUnsignedSmallInt Or adUnsignedInt Or adUnsignedBigInt rs(strDBField) = CInt(strField) Case adSingle Or adDecimal Or adNumeric rs(strDBField) = CSng(strField) Case adDouble rs(strDBField) = CDbl(strField) Case adCurrency rs(strDBField) = CCur(strField) Case adBoolean rs(strDBField) = CBool(strField) Case adDate Or adDBDate Or adDBTime or adDBTimeStamp rs(strDBField) = CDate(strField) Case Else rs(strDBField) = CStr(strField) End Select If fp_Debug Then strError = "Cannot save value """ & strField & """ to database field """ & strDBField & """" Else strError = "Cannot save value to database field" End If FP_DumpError strErrorUrl, strError Err.Clear End Function Thanks, Steve |
|
#7
|
||||
|
||||
|
Is there something in the global.asa session_onend which is deleting data?
|
|
#8
|
|||
|
|||
|
Not sure, but here's the function you mentioned....
Sub Session_OnEnd ' Decrease the active visitors count when the session ends. Application.Lock Application("ActiveUsers") = Application("ActiveUsers") - 1 Application.UnLock End Sub |
|
#9
|
||||
|
||||
|
if the data is in the table while your logged in, there must be a delete statement somewhere in your application
![]() |
|
#10
|
||||
|
||||
|
This is certainly a strange one... The code shown (for session_onend) doesn't affect the DB at all.
I assume there is a logout page also? Can you post that code please |
|
#11
|
|||
|
|||
|
I can login straight after registering, logout, and even login again. Just seems to be after browser has been shut a while, the info gets wiped!!
|
|
#12
|
|||
|
|||
|
Quote:
Here's the logout code mate...it's only a couple of lines mind... <% Session.Abandon () Response.Redirect ("main.asp") %> <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> <base target="_blank"> </head> <body> </body> </html> Thanks, Steve |