This topic is locked
[SOLVED]

 Event syntax

12/27/2007 3:41:19 PM
ASPRunnerPro General questions
author

In an earlier post Stealth showed me how to enter the timestamp as an event. The timestamp works fine, but now I'm having issues with the username. Below is the event code. Can anyone spot the error? Thanks. The error is "Undefined function 'Session' in expression."
'** Insert a record into another table ****

strSQLInsert = "insert into logins (x_username, x_datetime, value1) values (Session('UserID'), now(), 'Comment added')"

dbConnection.Execute strSQLInsert

S
stealthwifi 12/27/2007

Smacky,
I'm going to assume the code that is not working is being put in the After Unsuccessfull event. The reson it's not working is I dont think After unsuccess can handle the Session paramater since a session wasn't started. Try using the post value instead heres your code hopefully fixed:
'** Insert a record into another table ****

USERID = UCase(postvalue("username"))

strSQLInsert = "insert into logins (x_username, x_datetime, value1) values (' " & USERID & " ', now(), 'Comment added')"

dbConnection.Execute strSQLInsert
For my unsuccessfull event I use the following code:
[codebox]'** Insert a record into another table ****

LogDate = now()

USERID = UCase(postvalue("username"))

MACHIP = Request.ServerVariables("REMOTE_ADDR")

PROXYIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

STATUS = "Failed"

strSQLInsert = "insert into LoginAttempts (LogDate, USERID, MACHIP, PROXYIP, STATUS )

values (' " & LogDate & " ', ' " & USERID & " ', ' "& MACHIP & " ',' " & PROXYIP & " ', ' " & STATUS & " ' ) "

dbConnection.Execute strSQLInsert[/codebox]
Cheers,

Stealth

501306 12/27/2007

Thanks, Stealth. the ' " & USERID & " ' doesn't crash the page, but it doesn't seem to insert the userid into the logins table. I'm putting this event in the After Record Added events. I'm going to try to mimic your unsuccessful event and adapt it for record add and edit - good idea? Thanks again.

Smacky,

I'm going to assume the code that is not working is being put in the After Unsuccessfull event. The reson it's not working is I dont think After unsuccess can handle the Session paramater since a session wasn't started. Try using the post value instead heres your code hopefully fixed:
'** Insert a record into another table ****

USERID = UCase(postvalue("username"))

strSQLInsert = "insert into logins (x_username, x_datetime, value1) values (' " & USERID & " ', now(), 'Comment added')"

dbConnection.Execute strSQLInsert
For my unsuccessfull event I use the following code:
[codebox]'** Insert a record into another table ****

LogDate = now()

USERID = UCase(postvalue("username"))

MACHIP = Request.ServerVariables("REMOTE_ADDR")

PROXYIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

STATUS = "Failed"

strSQLInsert = "insert into LoginAttempts (LogDate, USERID, MACHIP, PROXYIP, STATUS )

values (' " & LogDate & " ', ' " & USERID & " ', ' "& MACHIP & " ',' " & PROXYIP & " ', ' " & STATUS & " ' ) "

dbConnection.Execute strSQLInsert[/codebox]
Cheers,

Stealth

Sergey Kornilov admin 12/27/2007

Good idea is to check ASPRunnerPro documentation related to session variables:

http://www.xlinesoft.com/asprunner/docs/as...n_variables.htm
Session("UserID") is what you looking for.

501307 12/27/2007

Thanks. That's a handy list. I have it working except for the MACHIP and PROXYIP variables.

Good idea is to check ASPRunnerPro documentation related to session variables:

http://www.xlinesoft.com/asprunner/docs/as...n_variables.htm
Session("UserID") is what you looking for.

S
stealthwifi 12/28/2007

I would try using a Response.Write to write the MACHIP and see what is being displayed.
As for the ProxyIP unless there using a proxy that uses the X-Forward this will always be blank, it's just a added measure if they happen to use a common free proxy that uses X-Forward. You could try to find a public proxy and test it first against this proxy checker (shows the X_Forward_For) http://checker.samair.ru/
A public proxy that does use the X-Forward_For is: 218.5.18.131 and port 3128

If you test this vs the link above it will show the X-Forward_For and should also show in your app.
Cheers,

Stealth

500416 1/2/2008

Stealth and Sergey: The insert record event is working perfectly now! Two changes that may have helped were to increase the size of the MACHIP field to 255 and to make sure the srtSQLinsert line was on one line. Probably obvious to you, but not to a rookie like me... Thanks again.

I would try using a Response.Write to write the MACHIP and see what is being displayed.

As for the ProxyIP unless there using a proxy that uses the X-Forward this will always be blank, it's just a added measure if they happen to use a common free proxy that uses X-Forward. You could try to find a public proxy and test it first against this proxy checker (shows the X_Forward_For) http://checker.samair.ru/
A public proxy that does use the X-Forward_For is: 218.5.18.131 and port 3128

If you test this vs the link above it will show the X-Forward_For and should also show in your app.
Cheers,

Stealth