Results 1 to 4 of 4

Thread: Display customer data

  1. #1
    Join Date
    May 2006

    Display customer data

    My first page is a simple form that passes the username and password to this page after checking it in the database.

    I know very little about sql but i want to be able to display other account info on this page after the customer is logged in how would i display the customer number which is stored in cust_no

    response.write (display cust_no if userid = username stored in the variable)


    Option Explicit

    <!-- METADATA TYPE="typelib"
    FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
    <!-- #include file="Connectionstring.asp" -->


    ' variables
    dim cnStr
    dim rcSet
    dim frmUsername
    dim frmPassword
    dim sqlStr

    'store form input into variables
    frmUsername = Request.Form("username")
    frmPassword = Request.Form("password")

    'create connection and recordset objects
    Set cnStr = Server.CreateObject("ADODB.Connection")
    Set rcSet = Server.CreateObject("ADODB.Recordset")

    ' defining database connection (connectionstring.asp)
    cnStr.ConnectionString = path
    cnStr.Provider = provider

    ' execute sql and open as recordset
    sqlStr = "Select * From customer where userid = '" _
    & Request.Form("username") & "' and password = '" & Request.Form("password") & "'"

    ' Opens the returned values from the SQL as a recordset, ready for iteration by ASP
    set rcSet = cnStr.Execute(sqlStr)

    ' validate variables against database
    If (not rcSet.BOF) and (not rcSet.EOF) then
    response.cookies("validated_user") = frmUsername
    response.write "<h1>Login successful!</h1>"
    response.write "<p>Welcome " & rcSet.fields(1) & "</p>"

    response.write "incorrect username and/or password"
    end if

  2. #2
    Join Date
    Mar 2006
    If this data is stored in the same table then you can use the same way as you are displaying your welcome text.


    but then referring the other databasefields in your recordset.
    For Example :

    But remeber when your user has cookies disabled, this script doesn't work

  3. #3
    Join Date
    May 2006
    Wow that worked the only problem is if i browse to the page without logging in it displays the info for the first row of data in the sql database, but when i add the line of code to check for the cookie it won't take me to the page cause i think the cookie check is for every page after this one but i can't get the variables to transfer to any pages after this one.

    'this is the cookie check script
    if request.cookies("validated_user") = "" then
    end if

  4. #4
    Join Date
    Mar 2006
    Try using session objects. Thats much easier and you can pas variabels between different pages.

    For example if a user is logged in correctly then set :
    session("login") = "ok"

    At the top of every page just check if session("login") = "ok"
    else redirect the user to your login page.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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