How do I give specific users access to specific websites in PHP?

108
May 13, 2022, at 05:50 AM

I'm building a login system. My database looks like this
Lets say, after loggin in, the code recognizes who is currently logged in and sends them to a specific website, based on the content in their KURS field.
So user yyy would be send to lets say TG111.php
And user uuu would be send to lets say TG112.php

TG111.php looks like this

<?php
session_start();
    $sess = $_SESSION['KURS'];
    if ($sess !== 'TG111') {
      if ($sess !== 'TG112') {
        if ($sess !== 'TG113') {
          header("Location: index.php");
          exit();
        }
        else {
          header("Location: TG113.php");
          exit();
        }
      }
      else {
        header("Location: TG112.php");
        exit();
      }
    }
    else {
      header('Location: TG111.php');
      exit();
    }
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Hello</title>
  </head>
  <body>
    <a href="logout.php">Abmelden</a>
  </body>
</html>


But this doesn't work...

Answer 1

I'm not sure what you're looking for? but you can try to debug it to see what the problem, you can try using this in your if statement

if($sess == 'TG111') {
    header('Location: TG111.php');
    exit();
} elseif ($sess == 'TG112') {
    header("Location: TG112.php");
    exit();
} elseif ($sess == 'TG113') {
    header("Location: TG113.php");
    exit();
} else {
    header("Location: index.php");
    exit();
}
Rent Charter Buses Company
READ ALSO
Email verification with PHPMailer without sending link?

Email verification with PHPMailer without sending link?

I'm currently writing a chat program in PHP and AJAX and have PHPMailer installed and in use

110
What is a single pipe equivalent in dart?

What is a single pipe equivalent in dart?

I'm attempting to convert a piece of PHP code to dart and I came across a few things I've simply never used before, one of which is a single pipe |Im not sure what the exact dart equivalent is, if there even is one

118
What is the proper way to do a foreach loop with an Array/Map in dart?

What is the proper way to do a foreach loop with an Array/Map in dart?

I'm trying to convert a piece of PHP code to dart and getting stuckWhat I have is a PHP array text that gets run through a function called toUTF8 as follows:

105
Laravel Error: Details blade displays wrong data, displays previous column data

Laravel Error: Details blade displays wrong data, displays previous column data

I have a Details page that displays "short description", "Duration", and "description of tour" from a database

64