jæja….
iss mig, en samt
byrjar á því að gera access grunn, með töflu
sem heitir users
í users geriri þú field sem heita
id (AutoNumber)
name (Text) (notendanöfn)
pwd (Text) (lykilorð)
svo bætir þú userum inní töfluna
svo gerir þú asp skjal sem heitir default.asp sem verður login
síðan.
í það skrifar þú:
<?xml version="1.0" encoding="iso-8859-1"?><br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br><%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%><br>
<%<br>
var connTest_STRING = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\serverside-slóð
á grunn\\grunnur.mdb"<br>
%><br>
<%<br>
var LoginAction = Request.ServerVariables("URL");<br>
if (Request.QueryString!="") LoginAction += "?" + Request.QueryString;<br>
var valUsername=String(Request.Form("name"));<br>
if (valUsername != "undefined") {<br>
var fldUserAuthorization="";<br>
var redirectLoginSuccess="inni.asp";<br>
var redirectLoginFailed="default.asp";<br>
var flag="ADODB.Recordset";<br>
var rsUser = Server.CreateObject(flag);<br>
rsUser.ActiveConnection = connTest_STRING;<br>
rsUser.Source = "SELECT name, pwd";<br>
if (fldUserAuthorization != "") rsUser.Source += "," + fldUserAuthorization;<br>
rsUser.Source += " FROM users WHERE name='" + valUsername.replace(/'/g,
"''") + "' AND pwd='" + String(Request.Form("pwd")).replace(/'/g,
"''") + "'";<br>
rsUser.CursorType = 0;<br>
rsUser.CursorLocation = 2;<br>
rsUser.LockType = 3;<br>
rsUser.Open();<br>
if (!rsUser.EOF || !rsUser.BOF) {<br>
Session("Username") = valUsername;<br>
if (fldUserAuthorization != "") {<br>
Session("UserAuthorization") = String(rsUser.Fields.Item(fldUserAuthorization).Value);<br>
} else {<br>
Session("UserAuthorization") = "";<br>
}<br>
if (String(Request.QueryString("accessdenied")) != "undefined"
&& false) {<br>
redirectLoginSuccess = Request.QueryString("accessdenied");<br>
}<br>
rsUser.Close();<br>
Response.Redirect(redirectLoginSuccess);<br>
}<br>
rsUser.Close();<br>
Response.Redirect(redirectLoginFailed);<br>
}<br>
%><br>
<html xmlns="
http://www.w3.org/1999/xhtml"><br><head><br>
<title>Login</title><br>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/><br>
</head>
<p><body><br>
<form name="login" id="login" method="POST"
action="<%=LoginAction%>"><br>
<p>Username: <br>
<input name="name" type="text" id="name" size="15"
maxlength="50" /><br>
<br /><br>
Password: <br>
<input name="pwd" type="text" id="pwd" size="15"
maxlength="50" /><br>
<br /><br>
<input name="submit" type="submit" id="submit"
value="login" /><br>
</p><br>
</form><br>
</body><br>
</html><br>
og svo gerir þú skjal sem heitir tildæmis inni.asp og það
gæti litið svona út:
<?xml version="1.0" encoding="iso-8859-1"?><br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br><%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%><br>
<%<br>
// *** Restrict Access To Page: Grant or deny access to this page<br>
var authorizedUsers="";<br>
var authFailedURL="default.asp";<br>
var grantAccess=false;<br>
if (String(Session("Username")) != "undefined") {<br>
if (true || (String(Session("UserAuthorization"))=="") ||
(authorizedUsers.indexOf(String(Session("UserAuthorization"))) >=0))
{<br>
grantAccess = true;<br>
}<br>
}<br>
if (!grantAccess) {<br>
var qsChar = "?";<br>
if (authFailedURL.indexOf("?") >= 0) qsChar = "&";<br>
var referrer = Request.ServerVariables("URL");<br>
if (String(Request.QueryString()).length > 0) referrer = referrer + "?"
+ String(Request.QueryString());<br>
authFailedURL = authFailedURL + qsChar + "accessdenied=" + Server.URLEncode(referrer);<br>
Response.Redirect(authFailedURL);<br>
}<br>
%><br>
<html xmlns="
http://www.w3.org/1999/xhtml"><br><head><br>
<title>inni</title><br>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/><br>
</head>
<p><body><br>
you made it! <br>
</body><br>
</html><br>
þetta er allt svolítið stolið úr Dreamweaver MX
version 6.0
hafðu þetta nú, og farðu svo að læra serverside
forritun eða hættu að forrita serverside
þú getur prufað þetta á www.geislasteinn.is/login
username: test
password: test
ef þetta er óljóst (allt í bilum og læti,<b> sem þetta er örugglega</b>) getur
þú sótt kóðann á www.geislasteinn.is/login/code.html