PDA

View Full Version : Cần giúp đỡ về làm form login



Athrun
13-01-2011, 11:30
Mình đang dùng dreamweaver cs4 để làm 1 trang web , tuy nhiên khi làm form login thì có lỗi như sau : nếu làm bằng asp thì khi chạy thử bất kể nhập mật khẩu đúng hay sai cũng báo lỗi như sau

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

Please try the following:

* Click the Refresh button, or try again later.
* Open the localhost home page, and then look for links to the information you want.

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

* Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.
/Login.asp, line 17

* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; vi; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

* Page:
POST 76 bytes to /Login.asp

* POST Data:
username=&password=&%C4%90%C4%83ng++nh%E1%BA%ADp=%C4%90%C4%83ng+nh%E1% BA%ADp

* Time:
Thursday, January 13, 2011, 11:17:45 AM

* More information:
Microsoft Support


Form login bằng asp như sau


<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/MyConnection.asp" -->
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables("URL");
if (Request.QueryString != "") MM_LoginAction += "?" + Server.HTMLEncode(Request.QueryString);
var MM_valUsername = String(Request.Form("username"));
if (MM_valUsername != "undefined") {
var MM_fldUserAuthorization = "Tên nguo`i su? du?ng";
var MM_redirectLoginSuccess = "Camera.html";
var MM_redirectLoginFailed = "Login.asp";

var MM_loginSQL = "SELECT [Tên nguo`i su? du?ng], [Mâ?t khâ?u]";
if (MM_fldUserAuthorization != "") MM_loginSQL += "," + MM_fldUserAuthorization;
MM_loginSQL += " FROM Username WHERE [Tên nguo`i su? du?ng] = ? AND [Mâ?t khâ?u] = ?";
var MM_rsUser_cmd = Server.CreateObject ("ADODB.Command");
MM_rsUser_cmd.ActiveConnection = MM_MyConnection_STRING;
MM_rsUser_cmd.CommandText = MM_loginSQL;
MM_rsUser_cmd.Parameters.Append(MM_rsUser_cmd.Crea teParameter("param1", -1, 1, -1, MM_valUsername)); // N/A
MM_rsUser_cmd.Parameters.Append(MM_rsUser_cmd.Crea teParameter("param2", -1, 1, -1, Request.Form("password"))); // N/A
MM_rsUser_cmd.Prepared = true;
var MM_rsUser = MM_rsUser_cmd.Execute();

if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
if (MM_fldUserAuthorization != "") {
Session("MM_UserAuthorization") = String(MM_rsUser.Fields.Item(MM_fldUserAuthorizati on).Value);
} else {
Session("MM_UserAuthorization") = "";
}
if (String(Request.QueryString("accessdenied")) != "undefined" && false) {
MM_redirectLoginSuccess = Request.QueryString("accessdenied");
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginSuccess);
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginFailed);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
<p>Tên người dùng
<label>
<input type="text" name="username" id="Tên người dùng" />
</label>
</p>
<p>Mật khẩu
<label>
<input type="text" name="password" id="Mật khẩu" />
</label>
</p>
<p>
<label>
<input name="Đăng nhập" type="submit" id="Đăng nhập" value="Đăng nhập" />
</label>
</p>
<p><a href="MainPage.html">Về trang chủ</a></p>
<p>&nbsp;</p>
</form>
<p>&nbsp;</p>
</body>
</html>


Lỗi này có người nói là do máy không đọc được đến file database được , tuy nhiên database dạng mdb mình làm bằng access không bị đánh dấu read only hay gì hết , còn file ldb thì vốn bị khóa không thể mở ra được
Còn nếu làm bằng php thì lại không thể kết nối được với CSDL của mySQL , mỗi lần thử kết nối đều báo lỗi 405 mặc dù username và password là chính xác
Ai biết chỉ giùm mình, thx