Very New, Newbie Confused

Discussion in 'ASP .Net' started by Wizard, Jan 3, 2005.

  1. Wizard

    Wizard Guest

    Hello All,

    I`ve started learning ASP.Net and web design.

    I`ve download the Web Matixs Software but im very confused with something
    that i think is so simple. Here goes i`ve downloaded some example ASP code
    from the net, As below.

    How do i intergrate this into my web page? the code below is for a simple
    Username/Password thinggy.

    Many Thanks

    Regards
    Si

    <%@ Language = "VBScript" %>
    <%
    Option Explicit
    '**********************************************************
    ' To make this script work you simply need to create a
    ' table named tblLoginInfo in your database with one
    ' column named username and another named password. Put
    ' the values you want for username and password into a
    ' record in the table. The advantages of this script are
    ' that it's more secure than if you hard-coded the
    ' username/password values directly in the script, and
    ' that you can change the username and password simply by
    ' changing the values in your login_table.
    '
    ' NOTE: BE SURE TO EITHER MOVE THE INCLUDED SAMPLE
    ' DATABASE TO A SECURE AREA OUTSIDE THE WEB SITE OR
    ' USE A DIFFERENT SECURE DATABASE. OTHERWISE ANYONE
    ' CAN SIMPLY DOWNLOAD THE WHOLE DB AND RETREIVE YOUR
    ' USERNAME AND PASSWORD FROM IT.
    '**********************************************************

    Dim cnnLogin
    Dim rstLogin
    Dim strUsername, strPassword
    Dim strSQL

    %>
    <html>
    <head><title>Login Page</title>
    </head>
    <body bgcolor="gray">
    <%
    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("login.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="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>
     
    Wizard, Jan 3, 2005
    #1
    1. Advertising

  2. The line "<%@ Language = "VBScript" %>" indicates Classic ASP (Version 3.0).
    Use code with <%@ Language = "VB" %> - that is ASP.NET VisualBasic .NET




    --
    Daniel Fisher(lennybacon)
    MCP ASP.NET C#
    Blog: http://www.lennybacon.com/


    "Wizard" <> wrote in message
    news:...
    > Hello All,
    >
    > I`ve started learning ASP.Net and web design.
    >
    > I`ve download the Web Matixs Software but im very confused with something
    > that i think is so simple. Here goes i`ve downloaded some example ASP code
    > from the net, As below.
    >
    > How do i intergrate this into my web page? the code below is for a simple
    > Username/Password thinggy.
    >
    > Many Thanks
    >
    > Regards
    > Si
    >
    > <%@ Language = "VBScript" %>
    > <%
    > Option Explicit
    > '**********************************************************
    > ' To make this script work you simply need to create a
    > ' table named tblLoginInfo in your database with one
    > ' column named username and another named password. Put
    > ' the values you want for username and password into a
    > ' record in the table. The advantages of this script are
    > ' that it's more secure than if you hard-coded the
    > ' username/password values directly in the script, and
    > ' that you can change the username and password simply by
    > ' changing the values in your login_table.
    > '
    > ' NOTE: BE SURE TO EITHER MOVE THE INCLUDED SAMPLE
    > ' DATABASE TO A SECURE AREA OUTSIDE THE WEB SITE OR
    > ' USE A DIFFERENT SECURE DATABASE. OTHERWISE ANYONE
    > ' CAN SIMPLY DOWNLOAD THE WHOLE DB AND RETREIVE YOUR
    > ' USERNAME AND PASSWORD FROM IT.
    > '**********************************************************
    >
    > Dim cnnLogin
    > Dim rstLogin
    > Dim strUsername, strPassword
    > Dim strSQL
    >
    > %>
    > <html>
    > <head><title>Login Page</title>
    > </head>
    > <body bgcolor="gray">
    > <%
    > 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("login.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="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>
    >
    >
    >
     
    Daniel Fisher\(lennybacon\), Jan 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    518
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,718
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    467
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    542
    Dave Thompson
    Feb 14, 2005
  5. Jim

    Very new - Very confused

    Jim, Aug 4, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    141
Loading...

Share This Page