Using Session Variable ?

Results 1 to 2 of 2

Thread: Using Session Variable ?

  1. #1
    Join Date
    Dec 1969

    Default Using Session Variable ?

    Hello all, I am creating a site for the office and i&#039;m using DWMX.I need some advice with Session Variables. I have been reading through the authentication section in the &#039;The Missing Manual&#039; 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 (in VBScript) 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&#039;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 variable near the top of the page...<BR>&#060;%<BR><BR>Dim UsrNm <BR>UsrNm = rstBookList.Fields.Item("UserName").Value<BR><BR>t hen further down where the code lists the records I have this code...<BR><BR> &#060;td&#062;&#060;% (Session("MM_Username")) = ("UsrNm") THEN %&#062;&#060;a href="editbook.asp?id=&#060;%=(rstBookList.Fields. Item("IDbk").Value)%&#062;"&#062;Edit&#060;/a&#062;&#060;% END IF %&#062;&#060;/td&#062;<BR><BR>The page does list all the records which was a good start AND it does not display the Edit button, however it doesn&#039;t display the Edit button for the person who has created the record. I created a record as MMitch and the session variable displayed the correct value but it did not display the Edit link for that record despite being a correct match. <BR>I suspect I went wrong somewhere in my code can someone please advise ? <BR><BR>Regards,<BR>Mitch...

  2. #2
    Join Date
    Dec 1969

    Default RE: Using Session Variable ?

    Could you show the code where you are setting the session variable MM_Username?<BR><BR>From the code you have given, it would not show the Edit button unless there was a match. Thus maybe your MM_Username or UsrNm variables are not getting set right. Try doing <BR><BR>response.write MM_Username & " - " & UsrNm<BR><BR>before your conditional statement to make certain of the values of the variables. <BR><BR>To answer your questions, lossly, you want to track the username in the record set of information (in this case &#039;rooms&#039;). Then you display only the &#039;rooms&#039; records were UsrNm = &#039;the users name&#039;. When they edit it you simply do a SQL UPDATE ... WHERE UsrNm = &#039;the users name&#039;.<BR><BR>If you are looking for more detail code on this, provide more of the code from the page.<BR><BR>Hope this helps.<BR><BR>- Olórin

Posting Permissions

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