Home >Web Front-end >HTML Tutorial >How to hide buttons from visitors on the front end and display them only after logging in_html/css_WEB-ITnose

How to hide buttons from visitors on the front end and display them only after logging in_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:50:142854browse

I hope you can help me a lot


Reply to the discussion (solution)

Only output the button after logging in, do not output if you are not logged in

Two methods, but the essence is the same;
1. Your back-end script language judgment, for example, after the user logs in, the user's number will be stored in the session, and after the user logs out, the session will be cleared, then in your On that page, just judge whether there is a value in the session. If there is a value, output your button, such as php

<?php     // 若session里存在userno这个变量,且该变量不为空。则输出按钮    if(isset($_SESSION['userno']) && !empty($_SESSION['userno'])):;?><input type="button" value="发言" id="submit"><?php endif ?>


2. The second is to judge the cookie. The button is hidden by default. Yes, after the user successfully logs in, the value is stored in the cookie, and then javascript determines whether there is a value in the cookie. If there is a value, the button is displayed.

The difference between these two methods is that in the first method, if the user does not log in, the user will never be able to find the button, and the button cannot be found on the page at all; while in the second method, the user will never be able to find the button. Here, the button already exists on the page, but it is hidden by default. It can still be displayed after the user modifies the CSS properties. It depends on your usage. The first method is recommended

Control the visibility of the button by judging the login identity

There are many ways to do this, it depends on which method you want to use,
The front-end can use js to control the button's disably.
The back-end can also control whether to output the button, or control the display and hide attributes of the button.
Anyway, you didn’t explain it clearly, and others don’t know how to answer you

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Mobile WebNext article:Mobile Web