Αρχή :: Ενότητες :: Scripting :: Απαντήσεις     
 

Forum

seek σε εγγραφή (θελω ακομη διαβασμα -το ξερω) - Από {(anonymous)}

Εχω μια βαση σε access με τους κωδικούς για την είσοδο του χρηστη σε ελεγχομενη περιοχη.
Αfου ο χρηστης δωσει τον σωστο κωδικο και μπει στην περιοχή, θέλω ΜΕ ΒΑΣΗ ΤΟ ΠΟΙΟΣ ΧΡΗΣΤΗΣ ΕΙΝΑΙ (προφανως με βαση τον κωδικό του) να του εμφανίζει ένα μήνυμα που του έχω αφήσει (10 λέξεις) στην αρχική ή σε άλλη βαση MDB.
Σημειοτεον οτι αφου δωσει τον σωστο κωδικο, "κυκλοφορεί" στην ελεγχομενη περιοχή με ...\selidaX.asp?name=ΧΧΧΧ

ευχαριστω - παραθετω μερικά απο τα αρχεια που χρησιμοποιω
==========================
<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session("blnIsUserGood")) = True then
'Redirect to unathorised user page
Response.Redirect"unauthorised_user_page.htm"
End If
%>






Prive - Αρχική σελίδα



<%
'Dimension Variables
Dim strUserName 'Holds the name of the user

'Get the users name passed from the previous page
strUserName = Request.QueryString("name")
%>







Α.Γ.Μ.Σ
<% =strUserName %>
καλωσόρισες στην ιδιωτική μας σελίδα.



 


 


....
==========================


<<<>>>>>>>





<%
'Dimension variables
Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim rsCheckUser 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim strUserName 'Holds the user name

'Initalise the strUserName variable
strUserName = Request.Form("txtUserName")

'Check the database to see if user exsits and read in there password
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "users"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
'strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath(strAccessDB)
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(strAccessDB)

'Set an active connection to the Connection object
adoCon.Open strCon

'Create a recordset object
Set rsCheckUser = Server.CreateObject("ADODB.Recordset")

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Password FROM tblUsers WHERE tblUsers.UserID ='" & strUserName & "'"

'Query the database
rsCheckUser.Open strSQL, strCon

'If the recordset finds a record for the username entered then read in the password for the user
If NOT rsCheckUser.EOF Then

'Read in the password for the user from the database
If (Request.Form("txtUserPass")) = rsCheckUser("Password") Then

'If the password is correct then set the session variable to True
Session("blnIsUserGood") = True

'Close Objects before redirecting
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing

'Redirect to the authorised user page and send the users name
Response.Redirect"pppp.asp?name=" & strUserName
End If
End If

'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing

'If the script is still running then the user must not be authorised
Session("blnIsUserGood") = False

'Redirect to the unautorised user page
Response.Redirect"unauthorised_user_page.htm"
%>

 


Απάντηση από:_tasos

Μία απλή λύση είναι το εξής.
Εφόσον χρησιμοποιείς μία μεταβλητή Session("") ,να δίνεις σε αυτήν τη μεταβλητή ως τιμή το username αυτού που έχει έχει μπει σωστά και έτσι θα θυμάσαι ποιος χρήστης είναι. Έτσι, αγού γνωρίζεις το χρήστη πιστέυω πως είναι εύκολο να εμφανίσεις το μήνυμα που θέλεις.
Αυτά, αν έχεις απορίες κάνε post εδώ ;-)

Απάντηση από:mengele

Mia allh koufh idea pou isws doulepsei.Dokimase na tous xeriseis se omades me ena neo pedio sth vash dedomenwn sou me times p.x. 1,2,3,4,5 ktl. Etsi h session "" 8a diavazei apeu8eias "priviledges" tou xrhsth kai den 8a xreiastei na xwriseis kai alles metavlhtes.

Elpizw na voi8isa

Euxaristw

Απάντηση από:p_p

Καταρχην ευχαριστω.
Με βολευει η 1η απαντησή σου καθοτι οπως έγραψα πριν <<αφου δωσει τον σωστο κωδικο, "κυκλοφορεί" στην ελεγχομενη περιοχή με ...\selidaX.asp?name=ΧΧΧΧ >>

ΟΜΩΣ, -όντως- το προβλημά μου είναι τι πρεπει να γραψω για να βρει την εγγραφή που θέλω μεσα στις 3000 εγγραφές και αφου τη βρει πως θα εμφανησει το σχόλιο που του άφησα.

thanks

Απάντηση από:Psaxtiris

εφόσον η σελίδα θα είναι της μορφής "..\selidaX.asp?name=ΧΧΧΧ"

strUser=Request.QueryString("name") //αντίστοιχα μπορείς να χρησιμοποιήσεις το Session

Set rs = Server.CreateObject("ADODB.Recordset")
//το query που θες για να τραβήξεις το μήνυμα π.χ
strSQL="Select * from tbl_Msg Where Msg_Recipient='"& strUser &"' Order by Msg_Date ;"
rs.Open strSQL, strCon



tip: Gr και διεθνή domain names με δωρεάν web hosting * F5 για νέο tip

   Πίσω στην προηγούμενη σελίδα






Η Εταιρία | Web Hosting | Domain names | Web Information | Υπηρεσίες | Resellers | Υποστήριξη |
Copyright © 2007–09 4GR.NETWORKS, All rights reserved.