<HTML>
<HEAD><TITLE>Login</TITLE></HEAD>
<BODY>
<%
user_id=request.form("user_id")
if user_id="" then
%>
<form name="frmLogin" method=post action="<%=Request("SCRIPT_NAME")%>">
Enter User ID<br>
<input name="user_id">
<br>
Enter Password<br>
<input type=password name="password">
<input name="OK" type="submit">
</form>
<%
else
Set CN = Server.CreateObject("ADODB.connection")
CN.Open "Provider=SQLOLEDB.1;Persist Security Info=True;" & _
"User ID=sa;Password=;" & _
"Initial Catalog=MyDatabase;Data Source=MyServer"
set RS = CN.execute("select * from USERS where USER_ID='" & _
request.form("user_id") & "'")
if RS.EOF then
%>
Invalid Login ID<br>
<a href="<%=Request("SCRIPT_NAME")%>">Try again</a>
<%
else
password=request.form("password")
if trim(RS.Fields("password"))=trim(password) then
if RS.Fields("usertype")="R" then
response.redirect("relatives.asp")
else
response.redirect("friends.asp")
end if
else
%>
Invalid Password<br>
<a href="<%=Request("SCRIPT_NAME")%>">Try again</a>
<%
end if
end if
end if
%>
</BODY>
</HTML>