Forums
This topic is locked
Problem updating and inserting data do MS Access
Posted 10 Jul 2007 14:01:46
1
has voted
10 Jul 2007 14:01:46 Diana Santos posted:
I'm working on a site with ASP technology (VBScript) and a MS Access database.Everything's been working just fine untill I started building the backoffice.
Since I've been using the Dreamweaver server objects to help me out and my server host didn't give direct access, I solved the problem using 2 different Connection files: one is used locally and refers to the database in Inetpub, the other is remote and uses de function "Mappath". I'm only telling this, in case it might has something to do with the problem I'm having.
So, when I build a page like a simple login to my users, and click the "submit" button on the form, the result is that it neither shows up any error nor it goes to a an of the pages I indicated on the "Login user" Server behaviour. It dows a refresh, and that's it.
Does anyone can help?
Here's the code for a simple login:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ligSocomage.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("_login")
If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
MM_redirectLoginSuccess="_entrada.asp"
MM_redirectLoginFailed="_erroLogin.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_ligSocomage_STRING
MM_rsUser.Source = "SELECT uLogin, uPass"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM Utilizadores WHERE uLogin='" & Replace(MM_valUsername,"'","''" &"' AND uPass='" & Replace(Request.Form("_pass","'","''" & "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username" = MM_valUsername
If (MM_fldUserAuthorization <> "" Then
Session("MM_UserAuthorization" = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization" = ""
End If
if CStr(Request.QueryString("accessdenied") <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied"
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form" name="formLogin" method="POST" action="<%=MM_LoginAction%>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right">login</div></td>
<td><input name="_login" type="text" id="_login" /> </td>
</tr>
<tr>
<td><div align="right">pass</div></td>
<td><label>
<input name="_pass" type="text" id="_pass" />
</label></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><label>
<input type="submit" name="Submit" value="Submit" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Replies
Replied 12 Jul 2007 15:02:59
12 Jul 2007 15:02:59 Seb Adlington replied:
Hi Diana,
Your code looks ok. If you are sure your connection to the database is working then maybe it's the Session settings on the server.
check the script is working by adding as below
in your code
....
....
....
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
' ADD THIS BIT HERE
Response.Write(Session("MM_Username") ' this should check whether the session is being written
' END
%>
ideally this should show you the username on screen - If not, have a play around trying to set some session variables and displaying them.
Cheers
Seb
Your code looks ok. If you are sure your connection to the database is working then maybe it's the Session settings on the server.
check the script is working by adding as below
in your code
....
....
....
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
' ADD THIS BIT HERE
Response.Write(Session("MM_Username") ' this should check whether the session is being written
' END
%>
ideally this should show you the username on screen - If not, have a play around trying to set some session variables and displaying them.
Cheers
Seb