Browse Source

Gestion de sessions référant et d'accès aux pages

master
BARRAUX Arthur 3 years ago
parent
commit
e5a7582d1c
  1. 12
      login.php
  2. 6
      prof/index.php
  3. 1
      prof/stylepage.css
  4. 2
      referant/index.php
  5. 2
      referant/liste.php
  6. 2
      referant/search.php
  7. 8
      session.php

12
login.php

@ -1,10 +1,16 @@
<?php
$good_login = 'prof';
$good_pwd = 'arthur';
$login = [['prof', 'arthur'], ['referant', 'azerty']];
echo $login[0][0];
if (isset($_POST['login']) && isset($_POST['pwd'])) {
if ($good_login == $_POST['login'] && $good_pwd == $_POST['pwd']) {
if ($login[0][0] == $_POST['login'] && $login[0][1] == $_POST['pwd']) {
session_start();
$_SESSION['login'] = $_POST['login'];
$_SESSION['pwd'] = $_POST['pwd'];
header('location: prof/index.php');
}
elseif ($login[1][0] == $_POST['login'] && $login[1][1] == $_POST['pwd']) {
session_start();
$_SESSION['login'] = $_POST['login'];
$_SESSION['pwd'] = $_POST['pwd'];

6
prof/index.php

@ -13,7 +13,11 @@ include '../session.php';
</head>
<body id="page">
<a class="champ" href="../referant/index.php">site référant</a>
<?php
if ($_SESSION['login'] == 'referant') {
echo '<a class="champ" href="../referant/index.php">site référant</a>';
}
?>
<h1 id="titre">
Formulaire de panne informatique
</h1>

1
prof/stylepage.css

@ -126,6 +126,7 @@ form{
padding: 15px;
margin: 0;
background-color: #dddddd;
}
.help * {

2
referant/index.php

@ -1,5 +1,5 @@
<?php
include '../session.php';
include '../session_restraintes.php';
?>
<!DOCTYPE html>

2
referant/liste.php

@ -1,5 +1,5 @@
<?php
include '../session.php';
include '../session_restraintes.php';
?>
<!DOCTYPE html>

2
referant/search.php

@ -1,5 +1,5 @@
<?php
include '../session.php';
include '../session_restraintes.php';
?>
<!DOCTYPE html>

8
session.php

@ -1,10 +1,10 @@
<?php
session_start();
if (!isset($_SESSION['login']) || !isset($_SESSION['pwd'])) {
print_r($_SESSION);
header('location: ../index.php');
if (isset($_SESSION['login']) && isset($_SESSION['pwd'])) {
echo 'vous etes autentifié';
}
else{
echo 'voous etes autentifié';
header('location: ../index.php');
}
?>
Loading…
Cancel
Save