-1

I am using this webpage password protector

It's working fine but i want to make the logged user's name appears in the protected page after logging in successfully. May you please help me ?

Zoe
  • 27,060
  • 21
  • 118
  • 148
DZ SAT
  • 3
  • 5

1 Answers1

1

Modify this part of your code:

  else {
    // set cookie if password was validated
    setcookie("verify", md5($login.'%'.$pass), $timeout, '/');

    // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
    // So need to clear password protector variables
    unset($_POST['access_login']);
    unset($_POST['access_password']);
    unset($_POST['Submit']);
  }

to read as:

  else {
    // set cookie if password was validated
    setcookie("verify", md5($login.'%'.$pass), $timeout, '/');

    echo "Username: " . $login;

    // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
    // So need to clear password protector variables
    unset($_POST['access_login']);
    unset($_POST['access_password']);
    unset($_POST['Submit']);
  }
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • great work @Fred -ii- now i could see the username .. but it appears only on the firs page then it disappear .. anyway to import to my secured pages ? – DZ SAT Mar 28 '15 at 14:55
  • @DZSAT Glad to hear it and that I was able to have been of help, *cheers!* – Funk Forty Niner Mar 28 '15 at 14:56
  • but it appears only on the firs page then it disappear .. anyway to import to my secured pages ? – DZ SAT Mar 28 '15 at 14:57
  • @DZSAT You'll need to apply the same logic for your other pages. However, you can use sessions for this and assign the username variable to a sessions array. – Funk Forty Niner Mar 28 '15 at 14:58
  • sorry dear Fred .. i'm not expert so i didn't understand what you mean – DZ SAT Mar 28 '15 at 15:00
  • 1
    @DZSAT Have a look at http://php.about.com/od/advancedphp/ss/php_sessions.htm and http://stackoverflow.com/q/7763720/ and http://www.thesitewizard.com/php/sessions.shtml - `session_start();` will be required to be used inside all files using sessions. – Funk Forty Niner Mar 28 '15 at 15:03
  • unfortunately bro ! .. i could not make this working – DZ SAT Mar 28 '15 at 15:22
  • please tell me how to import the $login to the other php files .. i was trying since yesterday but i didn't know – DZ SAT Mar 29 '15 at 18:08