Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-22, 06:57pm
Login Code
Subject: Login Code  ·  Posted: 2004-01-29, 05:28am
Rank: ? (1)
Member #: 13615
I really need help, I have to create a website as my third year college project and i havent a clue. Could anyone tell me code for user log in. Im using Notepad in HTML, ASP and MS Access-help 8(

 
  Reply to this ·  Post link ·  Top
Subject: Re: Login Code  ·  Posted: 2004-01-29, 07:23am
Rank: ? (4827)
Member #: 3416
that's a rather involved project . . . how much do you know about html, asp, and ms access?

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: Login Code  ·  Posted: 2004-01-29, 11:26am
Rank: ? (1200)
Member #: 12930
I think there is a tutorial on login script in this site, Let me look for it ... ... ... ... ... ... ... ... ... ... ... finally! I found it Here is the URL :
http://www.free2code.net/tutorials/programming/php/4/phplogin.php

So... How is life?
 
  Reply to this ·  Post link ·  Top
Subject: Re: Login Code  ·  Posted: 2004-01-29, 02:00pm
Rank: Unregistered
Very crude and simple login code... Let me know if you need any more complexity.
Note.. Since this is only for school it will do .. But if you plan to run this on an actual production site you need a LOT more to be secure.

First off create an MS Access Database... Call it "myDB.mdb" for simpicity.
Inside that DB .. Create a table called "tblUsers" Again.. You can rename this later but just for this, bare with me.
In that table, go to "Design view". Create two fields... A "UserID" field and a "Password" field.. Make the "UserID" field as the primary Key. Both fields must be as "text"


Now create a page called "login.asp"
Code:
  1. <% <------- ' If you're not familiar with ASP That is how we start off ASP code, so you absolutely need it there
  2. ' <-- This single quote is how we open comments... Anything following a s single quote like this will be ignored
  3. dim strDBPath, strConnection, strRecordSet, strSQL   '<-- These are the variables we use
  4. 'Comments --- >
  5. 'strDbpath is the directory and path of the location of your db... for simplicity we'll just put it in the same directory
  6. 'strConnetion is the actuall connection object..
  7. 'I'm using an old connection string because I don't know what drivers you may have installed .. This should run on anything.
  8. 'strRecordSet creates the record selection
  9. 'strSQLis the actual record selecter.. This is what the script uses to browse through all the records for a match
  10. '<--End comments
  11. strDBPath = "myDB.mdb"  '<---since we're using the same directory for everything.. We'll leave this as-is
  12. Set strConnection = Server.CreateObject("ADODB.Connection")   ' Now we set the connection
  13. strConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("" & strDBPath& ";")  '<--  We open the connection
  14. strSQL = "SELECT * FROM tblUsers WHERE UserID = '"& Request.Form("username") &"' AND Password = '"&Request.Form("password")&"'
  15. 'Ok.. now in this part we tell the string to select everything (*) from the table called "tblUsers" and search for an occurence of where
  16. 'the user ID matches the given user ID and password matches that user ID.   
  17. Set strRecordSet = strConnection.Execute(strSQL)  '<--- Tells the server .. "Go do the search! "  :P
  18. If Not RSuser.BOF And Not RSuser.EOF Then  '<-- The records did find a match.. As in NOT no match .. I know ASP likes it that way
  19.     Session("UserLogged") = True      '<-- Create a session variable where the user is shown to be logged in.
  20. End If                                             '<-- Close the IF statement



Now that's the end of the actual login page... Now you'll have to create a basic html page that will hold the actual login form..
I put my login in a table so everything arranges nicely...


Here's the login.html file
Code:
  1. <html>
  2. <head>
  3. <title>Login to enter</title>
  4. <meta name="generator" content="ghostnet" />
  5. </head>
  6. <body>
  7. <form action="login.asp" method="post">
  8. <table>
  9.     <tr>
  10.           <td> Username : </td><td><input type="text" name="username"></td>
  11.     </tr>
  12.     <tr>
  13.           <td> Password : </td><td><input type="password" name="password"></td>
  14.     </tr>
  15. </table>
  16. </body>
  17. </html>



Now that should be all... If this doesn't run let me know.. Of course it may not right off the bat because I just typed it here :P So we'll see
 
  Reply to this ·  Post link ·  Top
Subject: Re: Login Code  ·  Posted: 2004-01-29, 02:04pm
Rank: ? (115)
Member #: 4296
Oops.. That was me.. I took so long to type my session ran out lol

One thing... the <img stuff in there are just smilies.. I guess I shouldn't have used them there

And the comments are not aligned properly... For some reason it didn't scroll horizontally 8(

_unixsucks dot com_
 
  Reply to this ·  Post link ·  Top
Subject: Re: Login Code  ·  Posted: 2004-02-04, 02:35pm
Rank: ? (117)
Member #: 7875
I would suggest PHP over ASP. Is one of the requirements that it be in ASP? The F2C PHP/MySQL user authentication script is actually really good.

_______________________ AIOFREAK
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs