Browse Source

Nouvelle bdd pour les logins et modif structure

master
BARRAUX Arthur 3 years ago
parent
commit
8b8bb7ccb5
  1. 13
      index.php
  2. 26
      login.php
  3. 19
      login/cible.php
  4. 31
      login/index.php
  5. 4
      prof/index.php
  6. 2
      prof/script.js
  7. 146
      prof/stylepage.css
  8. 2
      referant/include/menu.php
  9. 2
      referant/index.php
  10. 2
      referant/search.php
  11. 6
      session.php
  12. 12
      session_restraintes.php
  13. 225
      stylepage.css
  14. 23
      ticket.sql

13
index.php

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action="login.php" method="post">
Login: <input type="text" name="login"><br>
Pwd: <input type="password" name="pwd"><br>
<input type="submit" value="conexion">
</form>
</body>
</html>

26
login.php

@ -1,26 +0,0 @@
<?php
$login = [['prof', 'arthur'], ['referant', 'azerty']];
echo $login[0][0];
if (isset($_POST['login']) && isset($_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'];
header('location: prof/index.php');
}
else {
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
}
else {
echo 'c vide';
}
?>

19
login/cible.php

@ -0,0 +1,19 @@
<?php
if (isset($_POST['login']) && isset($_POST['pwd'])) {
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', '');
$reponse = $bdd->query("SELECT * FROM logins");
while ($line = $reponse->fetch()) {
if ($line[0] == $_POST['login'] && $line[1] == $_POST['pwd']) {
session_start();
$_SESSION['login'] = $_POST['login'];
$_SESSION['pwd'] = $_POST['pwd'];
header('location: ../prof/index.php');
}
}
}
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
?>

31
login/index.php

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="../stylepage.css">
</head>
<body>
<form id='form' action="cible.php" method="post">
<div class="container-champ">
<p>Login:</p>
<div class="champ">
<select class="entry" name="login">
<option value="prof">prof</option>
<option value="referant">Référant</option>
</select>
</div>
</div>
<div class="container-champ">
<p>Pwd:</p>
<div class="champ">
<input class="entry" type="password" name="pwd">
</div>
</div>
<div class="container-champ">
<div class="champ">
<input class="entry" type="submit" value="conexion">
</div>
</div>
</form>
</body>
</html>

4
prof/index.php

@ -7,7 +7,7 @@ include '../session.php';
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Tickets de panne</title> <title>Tickets de panne</title>
<link href="stylepage.css" rel="stylesheet"> <link href="../stylepage.css" rel="stylesheet">
<script type="text/javascript" src="script.js" defer></script> <script type="text/javascript" src="script.js" defer></script>
<img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px"> <img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px">
@ -149,7 +149,7 @@ include '../session.php';
<div class="container-champ"> <div class="container-champ">
<br> <br>
<div class="submit"> <div class="submit">
<input id="submit" class="entry" type="submit" value="Valider"> <input class="entry" type="submit" value="Valider">
</div> </div>
</div> </div>

2
prof/script.js

@ -1,4 +1,3 @@
const button = document.getElementById('submit');
const page = document.getElementById('page'); const page = document.getElementById('page');
const check = document.getElementsByClassName('check'); const check = document.getElementsByClassName('check');
@ -10,7 +9,6 @@ const help = document.getElementsByClassName('help');
document.getElementById("form").addEventListener('submit', function(e) { document.getElementById("form").addEventListener('submit', function(e) {
e.preventDefault(); e.preventDefault();
if (checkInputs() == true) { if (checkInputs() == true) {
console.log('check');
var data = new FormData(this); var data = new FormData(this);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();

146
prof/stylepage.css

@ -1,146 +0,0 @@
head{
display: inline-table;
}
a{
color: #2ecc71;
}
body{
z-index: 1;
background-color: #e5e5e5;
margin: 20px;
text-align: center;
}
.logo{
display: block;
}
h1{
margin: 40px;
font-weight: bold;
color: #454545;
}
p{
font-weight: bold;
color: #454444;
font-size: 20px;
height: 20px;
}
form{
width: 400px;
position: relative;
background-color: #ffffff;
display: block;
margin: auto;
border-radius: 30px;
padding: 20px;
}
.container-champ{
position: relative;
}
.container-champ small{
display: none;
color: red;
}
.champ{
background-color: inherit;
display: flex;
position: relative;
text-decoration-line: none;
flex-direction: row-reverse;
text-align: center;
color: #454444;
display: block;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 10px 10px;
width: 200px;
border-radius: 30px;
transition: 0.25s;
}
.entry{
border: none;
resize: none;
outline: none;
width: 100%;
text-align: inherit;
background-color: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.champ:focus, .champ:hover{
width: 300px;
border-color: #ac2a8d;
background-color: #dddddd;
}
.champ img{
display: none;
position: relative;
float: right;
width: 20px;
bottom: 20px;
right: 20px;
}
.submit{
background-color: inherit;
display: flex;
position: relative;
flex-direction: row-reverse;
text-align: center;
color: #454444;
display: block;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 10px 10px;
width: 200px;
border-radius: 30px;
transition: 0.25s;
}
.submit:hover{
width: 250px;
background-color: #82E6AC;
border-color: #2ecc71;
}
.help{
display: none;
z-index: 2;
position: absolute;
width: 170px;
right: 0;
top: 30%;
border-radius: 30px;
padding: 15px;
margin: 0;
background-color: #dddddd;
}
.help * {
font-size: 14px;
width: 100%;
}
.help p{
position: relative;
}
code {
background-color: #aaa;
border-radius: 5px;
font-family: courier, monospace;
padding: 3px 5px;
}

2
referant/include/menu.php

@ -1,4 +1,4 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Admin ticket</title> <title>Admin ticket</title>
<link href="stylepage.css" rel="stylesheet"> <link href="../stylepage.css" rel="stylesheet">
<img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px"> <img class="logo" src="../img/logo_PC.png" alt="logo_PC" width="200px">

2
referant/index.php

@ -9,7 +9,7 @@ include '../session_restraintes.php';
</head> </head>
<body> <body>
<a id="lien-client" href="../prof/index.php">client</a> <a class="champ" href="../prof/index.php">client</a>
<?php include 'include/nav.php'; ?> <?php include 'include/nav.php'; ?>
<script type="text/javascript" src="js/index.js" defer></script> <script type="text/javascript" src="js/index.js" defer></script>
<table id="table"> <table id="table">

2
referant/search.php

@ -13,7 +13,7 @@ include '../session_restraintes.php';
<?php include 'include/nav.php'; ?> <?php include 'include/nav.php'; ?>
<form id="form" action="js/search.php" method="POST"> <form id="form" action="js/search.php" method="POST">
<div class="champ"> <div class="champ">
<input type="input" name="id"> <input class="entry" type="input" name="id">
</div> </div>
<div class="submit"> <div class="submit">
<input id="submit" class="entry" type="submit"> <input id="submit" class="entry" type="submit">

6
session.php

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

12
session_restraintes.php

@ -1,16 +1,6 @@
<?php <?php
session_start(); session_start();
if (isset($_SESSION['login']) && isset($_SESSION['pwd'])) { if ( !(isset($_SESSION['login']) && isset($_SESSION['pwd'])) && !($_SESSION['login'] == 'referant')) {
if ($_SESSION['login'] == 'referant') {
echo 'vous êtes référant';
}
else {
echo 'vous etes autentifié';
}
}
else{
print_r($_SESSION);
header('location: ../index.php'); header('location: ../index.php');
} }
?> ?>

225
referant/stylepage.css → stylepage.css

@ -5,24 +5,154 @@ body{
text-align: center; text-align: center;
} }
#lien-client{ .logo{
text-decoration: none;
display: block; display: block;
width: 10%; }
h1{
margin: 40px;
font-weight: bold;
color: #454545;
}
p{
font-weight: bold;
color: #454444; color: #454444;
font-size: 20px;
height: 20px;
}
/* Form */
form{
width: 400px;
position: relative;
background-color: #ffffff;
display: block;
margin: auto;
border-radius: 30px;
padding: 20px;
}
.container-champ{
position: relative;
}
.container-champ small{
display: none;
color: red;
}
.champ{
background-color: inherit;
position: relative;
display: block;
text-decoration-line: none;
text-align: center;
color: #454444;
margin: 10px auto; margin: 10px auto;
border: 4px solid #4e4d4d; border: 4px solid #4e4d4d;
padding: 10px 10px; padding: 10px 10px;
border-radius: 30px; border-radius: 30px;
width: 200px;
transition: 0.25s; transition: 0.25s;
} }
#lien-client:hover{ .champ:focus, .champ:hover{
width: 20%; width: 300px;
border-color: #ac2a8d; border-color: #ac2a8d;
background-color: #dddddd; background-color: #dddddd;
} }
.champ img{
display: none;
position: relative;
float: right;
width: 20px;
bottom: 20px;
right: 20px;
}
.entry{
border: none;
resize: none;
outline: none;
width: 100%;
text-align: inherit;
background-color: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.submit{
background-color: inherit;
position: relative;
display: block;
text-align: center;
color: #454444;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 10px 10px;
border-radius: 30px;
width: 200px;
transition: 0.25s;
}
.submit:hover{
width: 250px;
background-color: #82E6AC;
border-color: #2ecc71;
}
/* Indice */
.help{
display: none;
z-index: 2;
position: absolute;
width: 170px;
right: 0;
top: 30%;
border-radius: 30px;
padding: 15px;
margin: 0;
background-color: #dddddd;
}
.help * {
font-size: 14px;
width: 100%;
}
.help p{
position: relative;
}
code {
background-color: #aaa;
border-radius: 5px;
font-family: courier, monospace;
padding: 3px 5px;
}
/* Nav */
nav{ nav{
width: 80%; width: 80%;
margin-left: 10%; margin-left: 10%;
@ -66,6 +196,21 @@ nav a{
text-decoration: none; text-decoration: none;
} }
.menu:hover{
background-color: #59184E;
transition: .5s;
border-radius: 10px;
}
.menu:hover > a{
color: #fff;
font-weight: bold;
}
/* Table */
#table-search{ #table-search{
display: none; display: none;
} }
@ -85,11 +230,14 @@ table{
} }
td { td {
border: 1px solid #84878C;
background-color: #e5e5e5; background-color: #e5e5e5;
border: 1px solid #84878C;
border-radius: 5px; border-radius: 5px;
text-align: center;
color: #84878C; color: #84878C;
width: 7%; width: 7%;
} }
@ -98,69 +246,8 @@ th{
} }
.menu:hover{ /* SWITCH */
background-color: #59184E;
transition: .5s;
border-radius: 10px;
}
.menu:hover > a{
color: #fff; /*texte quand on passe la souris un bouton du menu*/
font-weight: bold;
}
.logo{
display: block;
}
.champ{
background-color: inherit;
position: relative;
text-align: center;
color: #454444;
display: block;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 20px 40px;
width: 40%;
border-radius: 80px;
transition: 0.25s;
}
.champ:focus, .champ:hover{
border-color: #ac2a8d;
background-color: #dddddd;
}
.champ input{
border: none;
outline: none;
font-size: 3em;
color: #aaa;
width: 100%;
text-align: inherit;
background-color: inherit;
}
.submit{
background-color: inherit;
position: relative;
text-align: center;
color: #454444;
display: block;
margin: 10px auto;
border: 4px solid #4e4d4d;
padding: 10px 10px;
width: 200px;
border-radius: 30px;
transition: 0.25s;
}
.submit:hover{
width: 250px;
background-color: #82E6AC;
border-color: #2ecc71;
}
.switch { .switch {
position: relative; position: relative;
@ -169,14 +256,12 @@ th{
height: 34px; height: 34px;
} }
/* Hide default HTML checkbox */
.switch input { .switch input {
opacity: 0; opacity: 0;
width: 0; width: 0;
height: 0; height: 0;
} }
/* The slider */
.slider { .slider {
position: absolute; position: absolute;
cursor: pointer; cursor: pointer;

23
ticket.sql

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Host: localhost -- Host: localhost
-- Generation Time: Oct 28, 2021 at 06:44 PM -- Generation Time: Oct 30, 2021 at 07:45 PM
-- Server version: 10.4.21-MariaDB -- Server version: 10.4.21-MariaDB
-- PHP Version: 8.0.10 -- PHP Version: 8.0.10
@ -23,6 +23,25 @@ SET time_zone = "+00:00";
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `logins`
--
CREATE TABLE `logins` (
`login` varchar(255) NOT NULL,
`pwd` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `logins`
--
INSERT INTO `logins` (`login`, `pwd`) VALUES
('prof', 'arthur'),
('referant', 'azerty');
-- --------------------------------------------------------
-- --
-- Table structure for table `pannes` -- Table structure for table `pannes`
-- --
@ -76,4 +95,4 @@ COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Loading…
Cancel
Save