html - Changing the function of a button based on if a user is logged in
问题描述
I am trying to create an application page within a website and currently, I have a button that takes users to an application when clicked. However, I only want users who are logged in to be able to work on the application so is there any way that I can put a conditional on the button so that if the user is not logged in it first takes them to the login page before taking them to the application page.
解决方案
So basically need to use sessions to check if user is already logged in or nor. You can't do it in HTML. If you are using backend language for example PHP, then you can do it in this way:
<?php
session_start();
if(isset(SESSION_["user"]){
//do task which you want to do if user is logged in
}
else{
//do task when user is not logged in
}
?>
推荐阅读
- r - 查询某个元素在列表中的比例
- html - 如何使用 HTML/CSS 添加边框线
- css - 来自另一个不可见 SVG 的 SVG 过滤器完全移除目标
- javascript - 带有 ID 的 React Datatable 组件中的编辑按钮
- google-play - Google Play 中的 gsutil 工具提取数据的数据类型是什么
- angular - Angular 无法读取未定义错误的属性“GetCarList”
- python - 比较未对齐的系列列 Pandas
- python - 设计 django Relation 以便以后轻松保存数据
- reactjs - React Typescript:将字符串数组呈现为无序列表
- python-3.x - BeautifulSoup 无法读取 wiki 页面