View Single Post
  #3 (permalink)  
Old Oct 25th, 2007, 05:18
Monie Monie is offline
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,604
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: ASP-MySQL: Advance Login Page [Part 3: Welcomming The User To The Protected Page]

Welcome to Part 3 of our tutorial...

Congratulation! You have successfully logged on into the protected page!

This is basically a simple page. The only important things in this page is the Log Out button/link, where it will cleared off the session variable stored during the login verification,
and don't forget to greet your user with displaying their Fullname or what ever you like, in this tutorial, I'll use their Fullname that I' have drag from the database!

Code: Select all
<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%    
    'This page will not be cache by the browser (security reason)!
    Response.CacheControl = "no-cache"
    Response.AddHeader "Pragma", "no-cache"
    Response.Expires = -1
    
     'This will make sure no user can access this page without login into the system first,
    'If the user type this page address directly into the browser, they will be redirected into the login page!
     If Session("name") = "" Then
        Response.Redirect("login.asp")
     End If
     
    'Open database for greeting user purpose!
    'Database MySQL connection
    Dim connectionString, conn, rs    
    connectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; UID=root; PASSWORD=mypassword;"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open(connectionString)
    'At this line of sql statement, we are only quering the database for the particular information about the user!
    Set rs = conn.Execute("SELECT * FROM userlogin WHERE username = '" & Session("name") & "'")
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-16" />
<title>ASP Login Page</title>

<!-- Link to external style sheet  -->
<link rel="stylesheet" type="text/css" title="default" href="login.css" />
</head>

<body>
    <fieldset id="fieldset">
        <legend id="loginLegend">Success Login Page</legend>
        <div id="position">
            <h1>Welcome <%=rs("fullname")%>!</p> <!--Greeting the user with their Fullname-->
            <p>This is a protected page!</h1>
            <h1>You have successfully logged in into this page!</h1>
            <h1><br /><a href="logout.asp">Log Out</a></h1>
        </div>
    </fieldset>
</body>
</html>
In the next tutorial, we will be looking into the Log Out page!