How to make an page only accessible when logged in

FlOrInAs14

How to make an page only accessible when logged in, in PHP?

I want you when you click on the background to defend two buttons with Login And Register and you can only access these two buttons after you log in.

<?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>
Orange Orange

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


and logout.php must be

<?php 
session_start();
session_destroy();
header("Location:login.php");
?>

then, in login.php you write your login code

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Make page only accessible if logged in - Firebase Web

From Dev

Make folder only accessible for logged-in users on IIS7

From Dev

How to make a page not directly accessible in Flask?

From Dev

How to make files accessible only by root?

From Dev

How to make files accessible only by root?

From Dev

How to make a function accessible to certain classes only?

From Dev

Make web-page accessible only after the user completes an action

From Dev

How to make HTML element to be displayed only when page is printed?

From Dev

How to make all the buttons in a page accessible through keyboard

From Dev

how to make buttons accessible throughout the page in windows phone 7

From Dev

How to make a .html file accessible through HTTP but only through a redirect?

From Dev

How to make the whole site accessible by the single admin only

From Dev

How to make a Django view ONLY accessible to Unauthenticated users?

From Dev

how to make a restful endpoint only accessible for specific users?

From Dev

How to make the file accessible only through its own server?

From Dev

How to make a .html file accessible through HTTP but only through a redirect?

From Dev

How to make a Django view ONLY accessible to Unauthenticated users?

From Dev

access page only if logged in with php

From Dev

How to prevent user to access login page in django when already logged in?

From Dev

Conditional page for logged user (Member Only Page)

From Dev

AngularJS and Django only allow an angular view to be accessible if user is logged in

From Dev

User restriction page when logged in

From Dev

How to make Xdebug only show backtrace when opening page, and not log the backtrace?

From Dev

How do I make a webRequest Event Page that only listens for events when a flag is set?

From Dev

Make a field accessible to ONLY its corresponding property?

From Dev

Make a specific file only accessible to the server

From Dev

Make a specific file only accessible to the server

From Dev

Make instance accessible by only one thread at the time?

From Dev

How to make name accessible in this code

Related Related

  1. 1

    Make page only accessible if logged in - Firebase Web

  2. 2

    Make folder only accessible for logged-in users on IIS7

  3. 3

    How to make a page not directly accessible in Flask?

  4. 4

    How to make files accessible only by root?

  5. 5

    How to make files accessible only by root?

  6. 6

    How to make a function accessible to certain classes only?

  7. 7

    Make web-page accessible only after the user completes an action

  8. 8

    How to make HTML element to be displayed only when page is printed?

  9. 9

    How to make all the buttons in a page accessible through keyboard

  10. 10

    how to make buttons accessible throughout the page in windows phone 7

  11. 11

    How to make a .html file accessible through HTTP but only through a redirect?

  12. 12

    How to make the whole site accessible by the single admin only

  13. 13

    How to make a Django view ONLY accessible to Unauthenticated users?

  14. 14

    how to make a restful endpoint only accessible for specific users?

  15. 15

    How to make the file accessible only through its own server?

  16. 16

    How to make a .html file accessible through HTTP but only through a redirect?

  17. 17

    How to make a Django view ONLY accessible to Unauthenticated users?

  18. 18

    access page only if logged in with php

  19. 19

    How to prevent user to access login page in django when already logged in?

  20. 20

    Conditional page for logged user (Member Only Page)

  21. 21

    AngularJS and Django only allow an angular view to be accessible if user is logged in

  22. 22

    User restriction page when logged in

  23. 23

    How to make Xdebug only show backtrace when opening page, and not log the backtrace?

  24. 24

    How do I make a webRequest Event Page that only listens for events when a flag is set?

  25. 25

    Make a field accessible to ONLY its corresponding property?

  26. 26

    Make a specific file only accessible to the server

  27. 27

    Make a specific file only accessible to the server

  28. 28

    Make instance accessible by only one thread at the time?

  29. 29

    How to make name accessible in this code

HotTag

Archive