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 <?php
$good_login = 'prof'; $login = [['prof', 'arthur'], ['referant', 'azerty']];
$good_pwd = 'arthur'; echo $login[0][0];
if (isset($_POST['login']) && isset($_POST['pwd'])) { 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_start();
$_SESSION['login'] = $_POST['login']; $_SESSION['login'] = $_POST['login'];
$_SESSION['pwd'] = $_POST['pwd']; $_SESSION['pwd'] = $_POST['pwd'];

6
prof/index.php

@ -13,7 +13,11 @@ include '../session.php';
</head> </head>
<body id="page"> <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"> <h1 id="titre">
Formulaire de panne informatique Formulaire de panne informatique
</h1> </h1>

1
prof/stylepage.css

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

2
referant/index.php

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

2
referant/liste.php

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

2
referant/search.php

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

8
session.php

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