Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Member VegaLA's Avatar
    Join Date
    May 2004
    Posts
    70
    Member #
    6035
    Hello all,
    I need some advice with Session Variables. I have ben reading through the authentication section in the 'The Missing Manual' book for Dreamweaver MX and it has been very helpfull. Using the session variable mm_Username I have got the asp page to display the username of the user that has logged in, however I would now like to use that to allow the user to edit records they have created themselves. For example I have created a asp page that allows them to book rooms in the office. They are booked by name, room and time start and time finnish. The asp page that list all the rooms booked from today onwards has also allows the users to edit the times by clicking the edit text next to each record, however anyone who logs in can edit someone else's booking. I would like it to only allow the person who booked the room/created the record to be able to edit that particular record. I read through the chapter in the book and typed in this code...

    <% IF Session("MM_Username") = "UserN" THEN %><a href="editbook.asp?id=<%=(rstBookList.Fields.Item( "IDbk").Value)%>">Edit</a><% END IF %>

    ...however having tested it myself it does not work, all the edit links have disapeared from the view and the one I created using my username is also not displayed, the one record that should actually show. I realize that the code above should not say "usern" but the variable that is used for username, however i do not know how to code this.
    Can anyone offer some advice please ?

    Mitch....

  2.  

  3. #2
    Banned
    Join Date
    Mar 2005
    Posts
    45
    Member #
    9233
    I have a really great suggestion for you. Throw all your ASP books, tutorials and material in the trash. ASP will never compete against PHP. Take this advice from a professional who has ran into so many walls with ASP.

    1. ASP does not support Cron Jobs. A vital tool in backend systems.
    2. ASP is component driven (it means slow).
    3. ASP often outputs errors that are not really the error. That is if you can even get ASP to output errors.
    4. MySQL runs circles around MS SQL.

    The list goes on!

    The only reason I learned ASP was for clients who wanted to pay extra money for extra time needed to deal with ASP.

  4. #3
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    You're right. ASP is a POS. I mean, all those "enterprise solutions" you keep hearing about - I don't wanna hear it. The whole world should be run with PHP and MySQL, because they're obviously a better choice.

    MSSQL? Stored Procedures? Waste of time I say. Who needs that extra "optimization" (it means slow).

    And don't even get me started with what a waste of time Object Oriented programming is... almost as stupid as those things they call regular expressions (it means waste of time).
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  5. #4
    Banned
    Join Date
    Mar 2005
    Posts
    45
    Member #
    9233
    Object Oriented Programming is for Software Development. It helps improve security and portability when writing code. Server side scripting has been portable since day one. That is because we don't compile server side scripts. So I don't know why ASP is pushing this Object Orientated stuff. I think they are just chasing their tale in a circle. Why do they keep coming up with new versions of ASP? I don't feel like spending half my day relearning how to setup a database connection. I also don't understand why corporate america keeps pushing ASP. Are they receiving kickbacks from the license fees for MS SQL and Microsoft products. What's the deal?

  6. #5
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    ASP(and .NET) is a very powerful framework. Why would you use OO? Because you're writing software. Just because it's server-scripting does't make it any less complex than most programs out there.

    Every language in the world continually evolves.. ASP is one of the giants out there next to PHP & JSP most noticably (although Ruby is gaining fast). Saying it's as bad as you did is no help... ASP is a great language - it's just different.

    And, as far as databases go - MSSQL is far more advanced than MySQL - but MySQL's main advantage? It's free. Major advantage.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  7. #6
    ACW
    ACW is offline
    Member
    Join Date
    Jul 2004
    Posts
    82
    Member #
    6554
    Quote Originally Posted by VegaLA
    <% IF Session("MM_Username") = "UserN" THEN %><a href="editbook.asp?id=<%=(rstBookList.Fields.Item( "IDbk").Value)%>">Edit</a><% END IF %>
    Keep in mind that comparing strings in ASP is case sensitive so you may want to change your code as follows...
    Code:
    <% IF LCase(Session("MM_Username")) = LCase(strYourUserN) THEN %><a href="editbook.asp?id=<%=(rstBookList.Fields.Item("IDbk").Value)%>">Edit</a><% END IF %>
    You should also add similar code to editbook.asp so that users don't change other people's records by manually changing the id.
    Affordable Business Web Site Hosting by Geo Redundant Hosting

  8. #7
    Banned
    Join Date
    Mar 2005
    Posts
    45
    Member #
    9233
    80% of the web runs on Linux which means PHP. MY SQL is much faster than MS SQL as well. And last I recall, I don't think ASP var's are case sensitive. Linux/Unix is case sensitive, not Windows.

  9. #8
    ACW
    ACW is offline
    Member
    Join Date
    Jul 2004
    Posts
    82
    Member #
    6554
    comparing strings in ASP is case sensitive

    strVariable is the same as strvariable but "captainmedia" does not equal "CaptainMedia".
    Affordable Business Web Site Hosting by Geo Redundant Hosting

  10. #9
    Banned
    Join Date
    Mar 2005
    Posts
    45
    Member #
    9233
    I thought you meant the name of the variable!

  11. #10
    Junior Member
    Join Date
    May 2005
    Location
    Savannah, GA
    Posts
    6
    Member #
    9971
    Quote Originally Posted by VegaLA
    <% IF Session("MM_Username") = "UserN" THEN %><a href="editbook.asp?id=<%=(rstBookList.Fields.Item( "IDbk").Value)%>">Edit</a><% END IF %>
    I may not be understanding you correctly, but are you retrieving the userid from the database? If so, you would just compare the session variable to the userid for that record

    Code:
    <%
    Dim userN
    Set userN=rstBookList.Fields.Item("youruseridfield").Value
    
    If userN = Session("MM_Username") THEN 
    %>
    <a href="editbook.asp?id=<%=(rstBookList.Fields.Item("IDbk").Value)%>">Edit</a>
    <% Else %> 
    Edit 
    <% END IF %>
    Of course, I'm assuming you have this in a loop to list all of the entries. The above code would only attach the link if the current user matches the userid from that particular record. Otherwise, it just just prints the word Edit.

    good luck

    digitaltheory


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:29 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com