我正在尝试制作一个由 asp 和 sql 提供支持的登录页面。点击提交后,表单甚至不会触发(即如果字段为空,则错误消息甚至不会显示)
这是我的代码:
<!DOCTYPE html>
<html>
<title>
Query
</title>
<link href="http://hr-computing/public/AlexS/Tests/Site.css" rel="stylesheet">
<body>
<div id="main">
<%
username = ""
password = ""
ErrorMessage = ""
if request.form <> "" then
username = Request.Form("firstname")
password = Request.Form("password")
if username = "" or password = "" then
ErrorMessage = "You must specify a username and password."
else
set conn=Server.CreateObject("ADODB.Connection")
conn.Open ="{private}
set rs=Server.CreateObject("ADODB.recordset")
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select firstname, PASSWORD FROM teachers WHERE firstname = '" & firstname & "'", conn
if rs.EOF = false then
if rs.fields("Password") = password then
Response.Redirect("http://hr-computing/public/AlexS/Tests/default.asp")
end if
end if
ErrorMessage = "Login failed"
end if
end if
%>
<h1>Login</h1>
<form method="post" action="http://hr-computing/public/AlexS/Tests/login.asp">
<fieldset>
<legend>Log In to Your Account</legend>
<ol>
<li>
<label>Username:</label>
<input type="text" id="firstname" name="firstname" />
</li>
<li>
<label>Password:</label>
<input type="password" id="password" name="password" />
</li>
<li>
<p><input type="submit" value="Login" /></p>
</li>
</ol>
</fieldset>
</form>
</div>
</body>
</html>
有人告诉我什么是错的,请。