Redirect to Changepassword page on default password

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
JAYM
User
Posts: 31

Redirect to Changepassword page on default password

Post by JAYM »

Redirect to Changepassword page on default password
I want to add function where if it detect the password of user when default password="12345" it will redirect to changepassword page upon logging in.
I tried to put the code to custom scripts but it doest work.
Please help thank you.

$userid = CurrentUserID();
    $pswd = ExecuteScalar("SELECT password FROM userlogin WHERE id='$userid'");

    if ($pswd == "12345"){
        header('Location: changepassword');
    } else{
      header('Location: home');
    }

mobhar
User
Posts: 11745

Post by mobhar »

Are you sure the password in users table are stored as plain text (not ecrypted)?


JAYM
User
Posts: 31

Post by JAYM »

Yes the password is not encrypted and its just plain text


mobhar
User
Posts: 11745

Post by mobhar »

In which server event did you put that code?


JAYM
User
Posts: 31

Post by JAYM »

I put the code here but is doesnt work
Global -> All Pages -> Page_loading
Global -> All Pages -> User_Validated
Table Specific -> Login Page -> UserLoggedIn


mobhar
User
Posts: 11745

Post by mobhar »

You should only put the code in User_LoggedIn server event.

In addition, change this part:
header('Location: changepassword');

to:
$this->terminate('changepassword');

and this part:
header('Location: home');

to:
$this->terminate('home');


JAYM
User
Posts: 31

Post by JAYM »

Thanks its working now.


Post Reply