Web Analytics Made Easy -
StatCounter login script question - CodingForum

Announcement

Collapse
No announcement yet.

login script question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • login script question

    Hi,

    I'm using a login script and everything is working great. I have managed to customize it so far, but there is one thing I can't manage.

    When a user clicks the login button, I would like the result to be a redirect to another page named client_area.htm.

    Here is the code, I'm sure it's something really simple.

    <%@ Language = "VBScript" %>
    <%
    Option Explicit

    Dim cnnLogin
    Dim rstLogin
    Dim strUsername, strPassword
    Dim strSQL

    %>
    <html>
    <head><title>IO Edit Login Page</title>

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }
    //-->
    </script>
    </head>
    <body bgcolor="white">
    <%
    If Request.Form("action") <> "validate_login" Then
    %>
    <form action="login_db.asp" method="post">
    <input type="hidden" name="action" value="validate_login" />
    <table border="0">
    <tr>
    <td align="right">Login:</td>
    <td><input type="text" name="login" /></td>
    </tr>
    <tr>
    <td align="right">Password:</td>
    <td><input type="password" name="password" /></td>
    </tr>
    <tr>
    <td align="right"></TD>
    <td><input type="submit" VALUE="Login" /></td>
    </tr>
    </table>
    </form>
    <%
    Else
    strSQL = "SELECT * FROM tblLoginInfo " _
    & "WHERE username='" & Replace(Request.Form("login"), "'", "''") & "' " _
    & "AND password='" & Replace(Request.Form("password"), "'", "''") & "';"

    Set cnnLogin = Server.CreateObject("ADODB.Connection")
    cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
    & "DBQ=" & Server.MapPath("IOlogin.mdb"))

    Set rstLogin = cnnLogin.Execute(strSQL)


    If Not rstLogin.EOF Then
    %>
    <p>
    <strong>All the Good Stuff We Want to Hide</strong>
    </p>
    <%
    Else
    %>
    <p>
    <font size="4" face="arial,helvetica"><strong>
    Login Failed - Please verify username and password.
    </strong></font>
    </p>
    <p>
    <a href="#" onClick="MM_goToURL('parent','login_db.asp');return document.MM_returnValue"login_db.asp">Try Again</a>
    </p>
    <%
    'Response.End
    End If

    ' Clean Up
    rstLogin.Close
    Set rstLogin = Nothing
    cnnLogin.Close
    Set cnnLogin = Nothing
    End If
    %>
    </body>
    </html>
    Last edited by kovalik; Feb 11, 2004, 07:05 PM.

  • #2
    Change it like this:

    Code:
    [b]If Not rstLogin.EOF Then
         Session("LoggedIn") = "True"
         Response.Redirect("client_area.asp")
    [/b]
    Else
    %>
    <p>
    <font size="4" face="arial,helvetica"><strong>
    Login Failed - Please verify username and password.
    </strong></font>
    </p>
    <p>
    <a href="#" onClick="MM_goToURL('parent','login_db.asp');return document.MM_returnValue"login_db.asp">Try Again</a>
    </p>
    <%
    'Response.End
    End If
    Then you can just check the session variable "LoggedIn" at the top of each page that you want to protect with an include file. In that include file, you'd just do something like:
    Code:
    <%
    If Session("LoggedIn") <> "True" Then Response.Redirect("somewhere")
    %>
    Hope I made that clear, otherwise your code looks ok from a quick overview (by that, hopefully I didn't miss anything!).

    P.S. You might want to quit using dreamweaver for JavaScript though... it generates totally unreadable (and in some cases just bad) code, you're better off learning JavaScript!

    P.P.S. Oh yeah... please note that I renamed your ".htm" file to ".asp" - which allows you to use ASP to help protect your page.
    Last edited by whammy; Feb 11, 2004, 08:48 PM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

    Comment


    • #3
      Thanks!

      Your help is very much appreciated

      georgia

      Comment


      • #4
        Let me know if it helps, I believe this will work...
        Former ASP Forum Moderator - I'm back!

        If you can teach yourself how to learn, you can learn anything. ;)

        Comment


        • #5
          It worked perfectly!

          Thanks again

          Comment


          • #6
            Former ASP Forum Moderator - I'm back!

            If you can teach yourself how to learn, you can learn anything. ;)

            Comment

            Working...
            X