How do I track who clicks a submit button?

65 views
Skip to first unread message

Austin Taylor

unread,
Mar 7, 2014, 5:01:03 PM3/7/14
to web...@googlegroups.com
I'm trying to figure out a way to track users who click the submit button. Maybe using their db.auth_user.username and appending it to a list whenever they click submit? I literally just have no idea where to start and any advice would be appreciated.

Best,

Austin

Anthony

unread,
Mar 7, 2014, 5:55:23 PM3/7/14
to
Depends on your goals. If we're talking about a SQLFORM based on a db table, it might make more sense to have a created_by and/or modified_by field in the table. The field(s) could be set to readable=writable=False, with the default set to auth.user_id. Whenever a record is inserted or updated, you then have the id of the user.

In any case, the current logged in user's id is in auth.user_id (which is None if the user isn't logged in), so you could store that wherever you like upon form submission.

Anthony

Austin Taylor

unread,
Mar 7, 2014, 6:20:46 PM3/7/14
to web...@googlegroups.com
Thank you so much, Anthony. What if I have multiple users logged in?
How would I store their ID upon clicking? Sorry I'm still learning I
know that is a noob question.

On Fri, Mar 7, 2014 at 5:54 PM, Anthony <abas...@gmail.com> wrote:
> Depends on your goals. If we're talking about a SQLFORM based on a db table,
> it might make more sense to have a created_by and/or modified_by field in
> the table. The field(s) could be set to readable=writable=False, and set the
> default to auth.user_id. Whenever a record is inserted or updated, you then
> have the id of the user.
>
> In any case, the current logged in user's id is in auth.user_id (which is
> None if the user isn't logged in), so you could store that wherever you like
> upon form submission.
>
> Anthony
>
>
> On Friday, March 7, 2014 5:01:03 PM UTC-5, Austin Taylor wrote:
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/JQayRnZibYA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

User

unread,
Mar 7, 2014, 6:52:33 PM3/7/14
to web...@googlegroups.com
What does the submit button do?

Anthony

unread,
Mar 8, 2014, 12:16:53 AM3/8/14
to web...@googlegroups.com
Each request is separate and independent. When a given user submits a form, a request is generated for that submit. In that request, the value of auth.user_id is the id of that particular user. When a different user submits the form, that generates an entirely new request, and in that request, the value of auth.user_id is the id of the second user (even if both submissions happen nearly simultaneously).

Anthony

Reply all
Reply to author
Forward
0 new messages