så det hele er med og jeg bare kan uploade det til min webisde for at se om det virker som det skal - altså bare på en blank side ikke alle mulige menuer - bare selve login-systemet
if request.form("Submit") = "Submit" then if dothis = "up" then MYSQL = "SELECT * FROM members WHERE usern = '" & usn & "'" rs1.open MYSQL, dataconn, 1, 3 rs1("level").value = "admin" rs1.update end if if dothis = "down" then MYSQL = "SELECT * FROM members WHERE usern = '" & usn & "'" rs1.open MYSQL, dataconn, 1, 3 rs1("level").value = "user" rs1.update end if if dothis = "del" then MYSQL = "SELECT * FROM members WHERE usern = '" & usn & "'" rs1.open MYSQL, dataconn, 1, 3 rs1.delete end if
rs1.close dataconn.close response.redirect "login.asp" end if
<body bgcolor="#FFFFFF" text="#000000"> <p>User update page, use this page to upgrade a user to admin level</p> <form name="form1" method="post" action="update.asp"> <p> <Select Name="usn"> <% MYSQL = "SELECT * FROM members" rs1.open MYSQL, dataconn, 1, 3 While Not rs1.EOF%> <option value="<%= rs1("usern") %>"><%= rs1("usern") %></option> <% rs1.MoveNext Wend %> </select> <p> <input type="radio" name="dothis" value="up"> Make user Admin<br> <input type="radio" name="dothis" value="down"> Make user Normal<br> <input type="radio" name="dothis" value="del"> Delete User Completely<br> <input type="submit" name="Submit" value="Submit"> </form> <% rs1.close dataconn.close %> </body> </html>
REG.ASP <% if request.form("reg") = "yes" then 'get variables from form usn = request.form("usn") pwd = request.form("pwd") pwd2 = request.form("pwd2") fname = request.form("fname") lname = request.form("lname") email = request.form("email")
'check varables are present and correct if usn = "" then err = 1 errmess = "You didnt insert a username<br>" end if if pwd = "" then err = 1 errmess = errmess & "You didnt insert a password<br>" end if if pwd2 = "" then err = 1 errmess = errmess & "You didnt insert a password again<br>" end if if fname = "" then err = 1 errmess = errmess & "You didnt insert your first name<br>" end if if lname = "" then err = 1 errmess = errmess & "You didnt insert your last name<br>" end if if InStr(email,"@") = 0 or InStr(email,".") = 0 or email = "" then err = 1 errmess = errmess & "You didnt enter a valid email address<br>" end if if pwd <> pwd2 then err = 1 errmess = errmess & "Your passwords dont match<br>" end if
if err = 0 then set dataconn = server.createobject ("ADODB.connection") set rs1 = server.createobject ("ADODB.recordset") 'dataconn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\login\db2.mdb" dataconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("db2.mdb")
MYSQL = "SELECT * FROM members WHERE usern = '" & usn & "'" rs1.open MYSQL, dataconn, 1, 3 if not rs1.EOF or not rs1.BOF then 'username exists already errmess = "Your choosen Username already exists" else
rs1.AddNew rs1.Fields("usern") = usn rs1.Fields("passwo") = pwd rs1.Fields("fname") = fname rs1.Fields("lname") = lname rs1.Fields("email") = email rs1.Update response.redirect "login.asp" end if rs1.close() dataconn.close() end if end if
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="19" align="center"> <tr> <td height="54" align="left"> <% ' BEGIN LOGON PROCEDURE dologin = request.form("login") usn = request.form("username") psw = request.form("password") if request.cookies("logoncookie")("cookname")<>"" then usn = request.cookies("logoncookie")("cookname") psw = request.cookies("logoncookie")("cookpass") dologin = "login" end if if request.form("logoff")="logoff" then dologin = "no" session("logon")="no" session("usn") = "" session("admin") = "no" session("superadmin") = "no" response.cookies("logoncookie").expires = date -1 end if 'decide whether to login or not if dologin ="login" then set dataconn = server.createobject ("ADODB.connection") set rs1 = server.createobject ("ADODB.recordset") 'dataconn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\login\db2.mdb" dataconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("db2.mdb")
MYSQL = "SELECT * FROM members WHERE usern = '" & usn & "'" rs1.open MYSQL, dataconn, 1, 3 if not rs1.EOF or not rs1.BOF then 'username checker if psw = (rs1("passwo")) then 'check password session("logon") = "yes" session("usn") = usn if rs1("level") = "admin" then session("admin") = "yes" if rs1("level") = "superadmin" then session("admin") = "yes" session("superadmin") = "yes" end if if request.form("rem") = "yes" then 'checkbox and create cookie response.cookies("logoncookie").Expires = date + 31 response.cookies("logoncookie")("cookname")= usn response.cookies("logoncookie")("cookpass")= psw end if else session("logon") = "no" 'incorect password error errmess="password incorrect" end if else errmess="Incorect Username" 'incorrect username error end if rs1.close() dataconn.close()
end if 'show user logged in if session("logon") = "yes" then call logonyes else 'show login required call logonno response.write errmess end if ' END LOGIN PROCEDURE %> </td> </tr> </table> <% function logonno() %> <form name="form1" method="post" action="login.asp"> Username <input type="text" name="username" size="17"> <br> Password <input type="password" name="password" size="17"> <br> Remember me <input type="checkbox" name="rem" value="yes"> <input type="submit" name="login" value="login"> </form> <p>Please click <a href="reg.asp">here</a> to register</p> <% end function
function logonyes() response.write "You are logged on as " & session("usn") if session("admin") = "yes" then response.write "<br>Admin Level Logon" if session("superadmin") = "yes" then response.write"<br><a href='update.asp'>Update Users</a>" %> <form name = "form1" method="post" action="login.asp"> <input type="submit" name="logoff" value="logoff"> </form> <% end function %> </body> </html>
hej - hvad er der galt når jeg uploader det virker ikke - efter at jeg har oprettet mig som bruger - sker der ikke noget. Jeg har vist ikke mysql med i mit webhotel pakke endnu - kommer en af dagene, men er det derfor eller mangler der et link - det virker sådan?
cool - nu virker det sgu. Lækkert - tak for hjælpen
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.