Browse Source

onglet admin terminé

master
BARRAUX Arthur 3 years ago
parent
commit
a4103bf904
  1. 1
      login/cible.php
  2. 45
      referant/admin.php
  3. 8
      referant/cible/admin.php
  4. 3
      referant/include/nav.php
  5. 26
      referant/js/admin.js
  6. 2
      referant/liste.php
  7. 14
      stylepage.css

1
login/cible.php

@ -12,6 +12,7 @@ if (isset($_POST['login']) && isset($_POST['pwd'])) {
header('location: ../prof/index.php'); header('location: ../prof/index.php');
} }
} }
$reponse->closeCursor();
} }
echo '<meta http-equiv="refresh" content="0;URL=index.php">'; echo '<meta http-equiv="refresh" content="0;URL=index.php">';

45
referant/admin.php

@ -0,0 +1,45 @@
<?php
include '../session_restraintes.php';
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', '');
$reponse = $bdd->query("SELECT * FROM logins");
$arr = [];
while ($line = $reponse->fetch()) {
$arr[$line[0]] = $line[1];
}
$reponse->closeCursor();
?>
<html>
<head>
<?php include 'include/menu.php'; ?>
<script type="text/javascript" src="js/admin.js" defer></script>
</head>
<body>
<?php include 'include/nav.php'; ?>
<table>
<thead>
<tr>
<th colspan="3">Mot de passe</th>
</tr>
</thead>
<tbody>
<tr class='table-title'>
<td>Login</td>
<td>Password</td>
</tr>
<tr>
<?php
foreach ($arr as $key => $value) {
echo '<tr>
<td class=',$key,' style="font-weight: bold;">', $key,'</td>
<td class=',$key,'>', $value,'</td>
<td class=',$key,'><input class="edit" type="button" value="edit" onclick="Edit(\'',$key,'\')"></td>
</tr>';
}
?>
</tr>
</tbody>
</table>
</body>
</html>

8
referant/cible/admin.php

@ -0,0 +1,8 @@
<?php
$decode = json_decode($_POST['value'], TRUE);
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', '');
$update = $bdd->query('UPDATE `logins` SET `pwd` = "' .$decode['pwd'] .'" WHERE `login` = "' .$decode['login'] .'"');
$traitement = $bdd->query("SELECT * FROM `logins` WHERE `login`= '" .$decode['login'] ."'");
print_r(json_encode($traitement->fetch()));
?>

3
referant/include/nav.php

@ -4,7 +4,8 @@
<li class="menu"><a href="index.php">Accueil</a></li> <li class="menu"><a href="index.php">Accueil</a></li>
<li class="menu"><a href="search.php">Recherche</a></li> <li class="menu"><a href="search.php">Recherche</a></li>
<li class="menu"><a href="liste.php">Liste</a></li> <li class="menu"><a href="liste.php">Liste</a></li>
<li class="menu"><a href="liens.html">Liens</a></li> <li class="menu"><a href="admin.php">Admin</a></li>
<li class="menu"><a href="export.php">Export</a></li>
</ul> </ul>
</nav> </nav>
</header> </header>

26
referant/js/admin.js

@ -0,0 +1,26 @@
function Edit(clas) {
let obj = document.getElementsByClassName(clas);
let data = new FormData();
if (obj[2].querySelector('input').value == 'edit') {
obj[1].innerHTML = '<input type="text" style="width: 80%;" value="' + obj[1].textContent + '">';
obj[2].querySelector('input').value = 'ok';
}
else {
let value = {};
value.login = obj[0].textContent;
value.pwd = obj[1].querySelector('input').value;
console.log(value);
let xhr = new XMLHttpRequest();
data.append('value', JSON.stringify(value));
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.response);
obj[1].innerHTML = this.response[1];
obj[2].querySelector('input').value = 'edit';
}
};
xhr.open('POST', 'cible/admin.php', true);
xhr.responseType = 'json';
xhr.send(data);
}
}

2
referant/liste.php

@ -11,7 +11,7 @@ include '../session_restraintes.php';
<body id="corps"> <body id="corps">
<?php include 'include/nav.php';?> <?php include 'include/nav.php';?>
<table> <table>
<thead> <thead>
<tr> <tr>
<th colspan="14">Ticket</th> <th colspan="14">Ticket</th>
</tr> </tr>

14
stylepage.css

@ -174,10 +174,11 @@ nav > ul::after{
} }
nav > ul > li{ nav > ul > li{
width: 25%; width: 20%;
float: left; float: left;
position: relative; position: relative;
text-align: center; text-align: center;
list-style-type: none;
} }
nav> ul > li > a{ nav> ul > li > a{
@ -185,20 +186,13 @@ nav> ul > li > a{
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
color: #eee; color: #eee;
} display: inline-block;
nav li{
list-style-type: none;
}
nav a{
display: inline-block;
text-decoration: none; text-decoration: none;
} }
.menu:hover{ .menu:hover{
background-color: #59184E; background-color: #59184E;
transition: .5s; transition: 1s;
border-radius: 10px; border-radius: 10px;
} }

Loading…
Cancel
Save