如何在登录时才能访问页面

时间:2017-12-12 14:05:27

标签: php

如何在PHP中登录时才能访问页面?

我希望您在单击背景时使用“登录和注册”来保护两个按钮,并且只能在登录后访问这两个按钮。

<?php
session_start();
include_once 'dbconnect.php';

?>
<!DOCTYPE html>

<HTML>
<head>
    <title>NCS pagina principala</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" >
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" >

</head>
<body>

                <?php if (isset($_SESSION['usr_id'])) { ?>
                <FONT size="4%" color="#66ffff" FACE="cursive">Esti conectat cu:</FONT><i><FONT size="5" color="#66ff66"> <?php echo $_SESSION['usr_name']; ?></FONT></i>

                <link rel="stylesheet" href="styles/buttonstyle.css">
                                 <a class="button" href="logout.php">Delogheaza-te</a>

                <?php } else { ?>
 <link rel="stylesheet" href="styles/buttonstyle.css">
<a class="button" href="login.php">Logheaza-te</a>
<a class="button" href="form.html">Cerere cont</a>
                <?php } ?>

<head>

<a class="button" href="blacklist.php">BlackList</a>
<CENTER>


<BODY STYLE = "BACKGROUND: url(https://cdn.discordapp.com/attachments/389773843813629972/389781868247253002/thumb-1920-553248.jpg); BACKGROUND-SIZE:130%"></BODY>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

</HTML>

1 个答案:

答案 0 :(得分:0)

试试这个(在session_start();之后):
from setuptools import find_packages, Extension from distutils.core import setup from distutils.core import setup from setuptools import find_packages, Extension from setuptools import setup, Extension setup( name='myapp', ext_modules=[ Extension('myapp.cython_module', ['myapp/cython_module.pyx']) ], )

和logout.php必须是

if (!isset($_SESSION['usr_id'])) header("Location:logout.php");

然后,在login.php中编写您的登录代码

相关问题