Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Validation of username logging in #9854

Closed
pjs13 opened this issue Feb 26, 2016 · 3 comments
Closed

Error in Validation of username logging in #9854

pjs13 opened this issue Feb 26, 2016 · 3 comments
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@pjs13
Copy link

pjs13 commented Feb 26, 2016

Hi,

I am using centos and have installed piwik in it.
I want to validate user's login on my website html page.
So my 1st page is test1.html and 2nd page will be test2.html.

I tried with using document.getElementById to capture the username from test1.html to test2.html like
Test1.html
<form action="test2.html>" onsubmit="MyFunction()" >
<input type="text" name="username" id="username"/>
<input type="submit" name="Login"/>
</form><script>
function MyFunction() { var username= document.getElementById("username"); }
Test2.html :
var _paq = _paq || []; _paq.push(['getUserId',username]); // _paq.push(['getUserId','"username'"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); `

even after doing this i am getting the username.
Plz help me to how to validate userlogin name.

@tsteur
Copy link
Member

tsteur commented Feb 26, 2016

I'm not sure what you mean by validating?

Possibly it is because of a type maybe. Can you try to remove the > in action="test2.html>".

_paq.push(['getUserId',username]); won't do anything as we do not save the username across requests. Maybe you want to call setUserId? In test2.html also make sure username is actually set.

@pjs13
Copy link
Author

pjs13 commented Feb 29, 2016

ya thanks for the replying.

Actually i need to get the value of username in my next page(page2.html). Where piwik stores that user_id in database and i get the username in my piwik plugin, where i have written a query to display user_Id. i.e select user_id from piwik_log_visit;

& if i remove form action then,how can i redirect to next page??

@tsteur
Copy link
Member

tsteur commented Mar 6, 2016

I'm sorry but I don't really understand what you are trying to achieve. AFAIK it is not possible to get the username on the next page via piwik.js. Actually, you kind of have to set the username on each request instead so piwik will always use the same username across requests of a specific user.

I'm not sure if a custom "Piwik plugin" can help you there either as Piwik won't really know which user it is when you query the API. Maybe try to store the username in a session or cookie within your regular application/website, then on each page request call _paq.push(['setUserId',usernameFromSessionOrCookieOr...]);.

@tsteur tsteur closed this as completed Mar 6, 2016
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Mar 6, 2016
@tsteur tsteur added this to the 2.16.1 milestone Mar 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants