| Server IP : 109.234.162.214 / Your IP : 216.73.216.222 Web Server : Apache System : Linux servd162214.srv.odns.fr 4.18.0-372.26.1.lve.1.el8.x86_64 #1 SMP Fri Sep 16 14:08:19 EDT 2022 x86_64 User : carpe ( 1178) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/carpe/www/CURSED/ |
Upload File : |
<?php
session_start();
include 'database.php';
$database = new Database();
$connexion = $database->getConnection();
if ($connexion) {
if(isset($_SESSION['login'])){
$username = $_SESSION['login'];
}
$sql = "SELECT * from users where pseudo = '$username'";
$statement = $connexion->prepare($sql);
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($results as $row) {
$id = $row['id_user'];
}
if(isset($_POST['cause2'])){
$cause2 = $_POST['cause2'];
if($cause2 == "supp"){
$sql = "DELETE FROM `inv` WHERE id_user = '$id'";
$statement = $connexion->prepare($sql);
$statement->execute();
}
if($cause2 == "take"){
$sql = "SELECT * from inv where id_user = '$id'";
$statement = $connexion->prepare($sql);
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($results as $row) {
echo $row['nom'];
echo ",";
echo $row['quantite'];
echo ".";
}
}
if($cause2 == "send"){
$nom = $_POST['nom'];
$quantite = $_POST['quantite'];
$sql2 = "DELETE FROM `inv` WHERE id_user = '$id'";
$statement2 = $connexion->prepare($sql2);
$statement2->execute();
$sql = "INSERT INTO `inv`(`id_user`, `nom`, `quantite`) VALUES ('$id','$nom','$quantite')";
$statement = $connexion->prepare($sql);
$statement->execute();
}
if($cause2 == "send2"){
$nom = $_POST['nom'];
$quantite = $_POST['quantite'];
$ind = 0;
$sql = "SELECT * from inv where id_user = '$id'";
$statement = $connexion->prepare($sql);
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($results as $row) {
$nom2 = $row['nom'];
$quantite2 = $row['quantite'];
if($nom2 == $nom){
$ind++;
}else{
}
/**
$sql = "INSERT INTO `inv`(`id_user`, `nom`, `quantite`) VALUES ('$id','$nom','$quantite')";
$statement = $connexion->prepare($sql);
$statement->execute();
**/
}
if($ind == 0){
$sql = "INSERT INTO `inv`(`id_user`, `nom`, `quantite`) VALUES ('$id','$nom','$quantite')";
$statement = $connexion->prepare($sql);
$statement->execute();
echo 'update1';
}else{
$sql = "UPDATE `inv` SET `quantite`='$quantite' WHERE id_user = $id AND nom = '$nom'";
$statement = $connexion->prepare($sql);
$statement->execute();
echo 'update2';
echo $quantite;
}
}
}
}
?>