LPCyber/tp5-files/webapp/admin/do_support.php

33 lines
923 B
PHP
Raw Normal View History

2022-03-24 08:31:23 +01:00
<?php
ob_start();
session_start();
echo "Login is ". $_SESSION['login'];
echo "&nbsp;<a href=login.php?logout=1>Logout</a><br/><br/>";
require_once("../db.inc.php");
// Gestion des ajouts/suppressions
if (isset($_POST['name'])) { // Ajout d'un nouveau client
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$password=$_POST['password'];
$role=$_POST['role'];
$query = "INSERT INTO clients (name, email, comment, password, role) VALUES ('$name','$email','$comment', '$password', '$role')";
pg_query($dbconn, $query) or die('Échec de la requête : ' . pg_last_error());
}
if (isset($_GET['delete'])) { // Suppression d'un client
$id = $_GET['delete'];
$query = "DELETE FROM clients WHERE id='$id'";
pg_query($dbconn, $query) or die('Échec de la requête : ' . pg_last_error());
}
// Ferme la connexion
pg_close($dbconn);
header('Location: print_clients.php');
?>