Results 1 to 11 of 11

Thread: Username Stamp

  1. #1
    Join Date
    May 2003
    Posts
    16

    Unanswered: Username Stamp

    Hi,

    I have an access database with one table on which users enter and modify data using ASP forms. I have another access database with one table which has all the username and password information and which processes the login. Is there a way where I can get the username stamp when someone enters the data into my database.

    Thanks

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Yes, of course there is.

    After accessing the login database, the username should be stored in a session variable. When the new page is loaded with info from the other database, the session variable is still available for use in code by the programmer. Any entries can then be 'stamped' with the username. You may need to create a username field in the 2nd table to hold the username, and modify the SQL statements moving the data to the db.

    This is basic ASP stuff. There are several good primers on the net to help you get started. Just enter ASP in your favorite search engine and you'll get a ton of sites.

    Tim
    Tim

  3. #3
    Join Date
    May 2003
    Posts
    16
    If I put this tag on my display.asp page then it shows my username from the other database <%= Session ("MyLoginNickName") %>

    I created a field in my access db called Createdby. Now how should I write the code in my add.asp form so that when I add something to the access db it records my username also. Please help.

    Thanks

  4. #4
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Originally posted by sajeed
    If I put this tag on my display.asp page then it shows my username from the other database <%= Session ("MyLoginNickName") %>

    I created a field in my access db called Createdby. Now how should I write the code in my add.asp form so that when I add something to the access db it records my username also. Please help.

    Thanks
    If the display.asp page is the first page, then right after wherever on the page that the Nick name is first defined, set up the session variable like this:

    Session("MyLoginNickName") = xloginNickName

    Somewhere in your add.asp file is an INSERT statement that takes the entered data and places it in the database.

    It should look something like:

    SQLx= "INSERT INTO (numfield1, strfield2, numfield3) VALUES (" & numvalue1 & ", '" & strvalue2 & "', " & numvalue3 & ")"

    Simply find this existing statement, and add your field to it...

    SQLx= "INSERT INTO (numfield1, strfield2, numfield3, createdby) VALUES (" & numvalue1 & ", '" & strvalue2 & "', " & numvalue3 & ", '" & Session ("MyLoginNickName") & "')"

    Notice the single quotes around the string variables.

    Hope this helps...

    Tim
    Last edited by MrWizard; 05-29-03 at 01:17.
    Tim

  5. #5
    Join Date
    May 2003
    Posts
    16
    Hi Tim,

    I am using Access 2000. I couldn't find any of those INSERT statements. Also can you tell me whether I need to put anything on the default value of the Createdby field in my table.

    Also display.asp is not my first page. My database consists of one table which has several fields on which I enter my daily shipping data using add.asp form. I was able to get the date/time stamp working successfully. I want it to record my username as well.

    Now I have other people who modify some data when the shipping is processed, they go to edit.asp form and change the status. I am able to get the modified date/time stamp as well. I want their usernames to get recorded as well when they modify something.

    My main database is daily.mdb with table name shipping
    My another database(which has all the login info) is MyLogin.mdb with table UserData

    On my shipping website, if I put this tag anywhere on my any page
    Hello <%= Session("MyLoginNickName") %> it shows Hello Sajeed which is right. But I want the code or instructions to set it up so that it can record my name in the Createdby field.

    Please help.

    Thanks

  6. #6
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    I am using Access 2000. I couldn't find any of those INSERT statements. Also can you tell me whether I need to put anything on the default value of the Createdby field in my table.
    There's got to be some code somewhere that adds the data into the database. From your description I'm guessing it's in the add.asp file.

    Instead of INSERT INTO... some programmers use something like:

    rstablename!fname = "Linda"
    rstablename!lname = "Kobara"
    rstablename.Update

    Either something similar to the above, or the INSERT INTO statement MUST be in your code somewhere.


    [On my shipping website, if I put this tag anywhere on my any page Hello <%= Session("MyLoginNickName") %> it shows Hello Sajeed which is right. But I want the code or instructions to set it up so that it can record my name in the Createdby field.
    Good. NOw that the session variable is set up, you can access it on ANY page, and use the NickName there.

    So, if you find an INSERT INTO statement, then do the modification per my previous post. If you find a .Update recordset command like the above, then add a line before the update command such as:

    rsShipping!Createdby = Session("MyLoginNickName")

    Hope this helps...

    Tim
    Tim

  7. #7
    Join Date
    May 2003
    Posts
    16
    Thank you so much Tim, you are the man :-)

    I didn't have the INSERT statments, but I had the rs. statement and I added rsShipping!Createdby = Session("MyLoginNickName") into my add.asp and then added rsShipping!Modifiedby = Session("MyLoginNickName") into my edit.asp and now I can easily find who added the record and who modified it. Thanks for your help.


    I have another question in which I need your help. On my daily.mdb database. I have the Shipping Table on which I have several fields. One of the field has options like UPS or USPS or Fedex. One of the other field has the options like Pending or Completed. Now is there a way in ASP where on my display.asp page, it shows me how many are in pending for UPS or USPS.

    The table field names are "Shipper" and "Status". I will really appreciate all your help. Thanks once again

  8. #8
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Originally posted by sajeed
    Thank you so much Tim, you are the man :-)

    I didn't have the INSERT statments, but I had the rs. statement and I added rsShipping!Createdby = Session("MyLoginNickName") into my add.asp and then added rsShipping!Modifiedby = Session("MyLoginNickName") into my edit.asp and now I can easily find who added the record and who modified it. Thanks for your help.


    I have another question in which I need your help. On my daily.mdb database. I have the Shipping Table on which I have several fields. One of the field has options like UPS or USPS or Fedex. One of the other field has the options like Pending or Completed. Now is there a way in ASP where on my display.asp page, it shows me how many are in pending for UPS or USPS.

    The table field names are "Shipper" and "Status". I will really appreciate all your help. Thanks once again

    You would just have to construct a SQL statement to do the query, and then execute it against the database.

    SELECT shipper, count(shipper) as Cnt from Shipping where status='pending' group by shipper

    It may take some testing to get exactly what you want, but something like the above should get you the total number of each shipper's pending records.

    If you're looking for a crosstab that also shows completed, then I'm afraid that gets much more complicated.

    Tim
    Tim

  9. #9
    Join Date
    May 2003
    Posts
    16
    Hi Tim,

    Can you please explain me in more details? How would I format this code and which page should I use in? list.asp (which displays all the records) or search.asp ?

    Also is it possible to get and record a person's computername and IP address? like when they add or modify records in my db, i should be able to see their computername and ip address if possible. Please let me know whenever you can. I will truly appreciate it.

    Thank you so much

  10. #10
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Originally posted by sajeed
    Hi Tim,

    Can you please explain me in more details? How would I format this code and which page should I use in? list.asp (which displays all the records) or search.asp ?

    Also is it possible to get and record a person's computername and IP address? like when they add or modify records in my db, i should be able to see their computername and ip address if possible. Please let me know whenever you can. I will truly appreciate it.

    Thank you so much
    Sorry, but I've already spent more time on this than I should have. I would suggest going to some ASP websites. Many have excellent code examples of how to do things. One I like is asp101.com.

    Good Luck...

    Tim
    Tim

  11. #11
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    sajeed - you should check;

    http://www.asp101.com
    http://www.w3cschools.com
    http://www.aspin.com
    http://www.activeserverpages.com/tutorials/
    http://www.101-asp-tutorials.com/
    http://www.htmlgoodies.com/beyond/aspdir.html
    http://www.aspdeveloper.net/
    http://www.kamath.com/tutorials/

    Also, try downloading the trial version of Macromedia Dreamweaver MX, it allows you to do most of the things you keep asking for very simply (click/drag etc).

    http://www.macromedia.com

    This forum is for asking questions rather than being taught nearly from scratch how to code an application, please read some of the above.

Posting Permissions

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