Page 1 of 1

Loging redirection

Posted: Thu Feb 16, 2017 11:38 pm
by alex4orly
I am using the Login object, on initial - first time entry I set the user name / password to the same value (using a csv flat file for data storage).
I want to "Force" the visitor to go on his first visit to a page to change his password.

I added two events - Onclick on the button, like this :

JavaScript function - checkEmail();
Onclick - Link to the relevant page in my project - this works as expected.

My checkEmail(); function is inserted into the HTML page just before the /body> tag, below is the function - but ' after the first login and the password change, the function is again behaving as if the username and password are still equal... WHY? I know they are not equal...

<script type="text/javascript">
function checkEmail()
{
if (loginform.username.value == loginform.password.value)
{
alert('Please update your password and your details');
.....;
} else {
.....;
}
}
</script>

Re: Loging redirection

Posted: Fri Feb 17, 2017 7:15 am
by Pablo
Although I cannot teach you how to write code, I doubt that this is correct/reliable:

Code: Select all

if (loginform.username.value == loginform.password.value)
Shouldn't you use this?

Code: Select all

document.getElementById("username").value;
Also note that login happens on the server (via PHP). So the values may not be valid in the browser.

Re: Loging redirection

Posted: Fri Feb 17, 2017 8:22 pm
by alex4orly
Well, it seems that the "Remember me" was the problem, maybe the cookies installed on my PC when I checked this option, would like to hear that I am wrong, because I really appreciate the benefit of this option.

Anyway, it now works with a single event on the Submit button - checkEmail();
And, the following JS function does the trick

Thanks Pablo

<script type="text/javascript">
function checkEmail()
{
if (loginform.username.value == loginform.password.value)
{
window.location.href='http://www.nmaa-rc.org.au/editprofile_html.php';
alert('The Password you used is just for first time visitors\rPlease change it and fill in the other details.\r Once you Submit changes - Log in again');
}
else
{
window.location.href='http://www.nmaa-rc.org.au/membershiprenewal.php';
}
}
</script>