Results 1 to 5 of 5

Thread: New user..new question..basic types..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    17

    Question New user..new question..basic types..

    i am a very new user to programming..i got into this coz i want to make my own website..and i am stuck at a point..

    how do i make user log in and logout using asp???

    i am sure i am between a panel of experts...

    any info would be appreciated


    thanx
    dev

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well I'm glad you'd like to learn.

    First you create a <FORM> element on one of your websites:
    Code:
    <FORM METHOD="POST" ACTION="login.asp">
    <INPUT TYPE="text" NAME="user"><BR>
    <INPUT TYPE="password" NAME="pass"><BR>
    <INPUT TYPE="submit">
    </FORM>
    Then, in your login.asp you would check it against a predefined list...
    VB Code:
    1. <%Dim User
    2. Dim Pass
    3.  
    4. User = Request.Form("user")
    5. Pass = Request.Form("pass")
    6.  
    7. If User = "my_name" and Pass = "my_password" Then
    8.    Response.Redirect "thankyou.htm"
    9. Else
    10.    Response.Redirect "bad.htm"
    11. End If%>
    This is the worst form of password authenification. If you want it better you wont encode the data being passed, as well as decode it at the other end. ASP does not do the decoding for you-- you must do it yourself.

    Another HUGE step up would be to access a database that contains a list of registered users and passwords.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    17

    Smile authentication

    hi

    thanx a lot for your help...

    i would like to go for the HUGE process option as i will have registered users accessing my website..hence i will have to make a db and simulatenously make a DSN on the server...but i dont know how to call a dsn and check the username and password and return the approprite results.....

    will that not be a better process to authenticate the users..in case of only registered users accessign the web page...???

    could you also pls elaborate about encoding and decoding ...and how do i do it....

    thanx once again

    dev

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    To encode it, I believe you would add this parameter to the form:
    Code:
    <FORM METHOD="POST" ACTION="login.asp" ENCTYPE="multipart/form-data">
    I have no idea how to decode it =), as ASP won't do it for you.

    To do the database, you would have this kind of code... and remember to have an ADOVBS.inc in your dir with all the correct stuff.
    Code:
    <!-- #INCLUDE FILE="adovbs.inc" --><%Dim User
    Dim Pass
    Dim CN
    Dim oC
    Dim oR
    
    User = Request.Form("user")
    Pass = Request.Form("pass")
    Set oC = Server.CreateObject("ADODB.Connection")
    Set oR = Server.CreateObject("ADODB.Recordset")
    
    CN = "DSN=[dsn-name]"
    
    oC.Open CN, [db_user_if_any], [db_password_if_any]
    oR.Open "SELECT * FROM USERS Where Username = '" & User & "'"
    
    If oR.EOF Then
       Response.Redirect "user_not_registered.htm"
    ElseIf UCASE(oR("Password")) <> UCASE(Pass) Then
       Response.Redirect "bad_pass.htm"
    Else
       Response.Redirect "thankyou.htm"
    End If%>
    You would have to have a table called USERS of course, with two fields, USERNAME and PASSWORD. This is only a small example. That should get you started but don't expect me to write that much code again =)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    17

    Smile login

    thanx for your help..i will figure out the rest and definitely will let post it on this forum..if i am able to elp others.


    thanx


    dev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width