How to change login and logout links dynamically in HTML page in PHP?

后端 未结 4 1618
梦谈多话
梦谈多话 2021-01-01 06:11

I have the following HTML code. I have 2 php files: login.php and logout.php. When any user first comes to my page, I would like him to see the login link. After clicking lo

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-01 06:47

    I am assuming you are using a session to check whether user logged in or not. If not, create a session variable and set once logged in. Clear the session variable on log out. So you can check

    if(isset($_SESSION['logged_in'])){
    //your logout link
    }else{
    //your login link
    }
    

提交回复
热议问题