update_status.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. $host = "kurek620.beget.tech";
  3. $username = "kurek620_baze";
  4. $password = "6910WASD579h";
  5. $database = "kurek620_baze";
  6. $mysql = new mysqli($host, $username, $password, $database);
  7. if($mysql->connect_error){
  8. die("Ошибка подключения". $mysql->connect_error);
  9. }
  10. $id = $_POST["id_hider"];
  11. $count_order = $_POST["id_count_s"];
  12. $login = $_POST["login_orders"];
  13. $summ_order = $_POST["summ_order"];
  14. $id_product = $_POST["hide_product"];
  15. $setting = $_POST["hide_c"];
  16. $product_id = $_POST["hide_pr"];
  17. $query = "UPDATE Products SET count_p = count_p - $setting WHERE id = $product_id";
  18. $result = $mysql->query($query);
  19. if(!$result){
  20. echo "Что то не так" . $mysql->error;
  21. }
  22. else{
  23. echo "<script>window.location.href = 'admin_page.php';</script>";
  24. }
  25. $query = "DELETE FROM Orders1 WHERE id = $id";
  26. if ($mysql->query($query) === TRUE) {
  27. echo "<script>window.location.href = 'admin_page.php';</script>";
  28. } else {
  29. echo "Ошибка при удалении записи: " . $mysql->error;
  30. }
  31. $query = "INSERT INTO Orders (`login`, `count_order`, `summ_order`, `id_product`)
  32. VALUES ('$login', '$count_order', '$summ_order', '$id_product')";
  33. $result = $mysql->query($query);
  34. if(!$result){
  35. echo "Что то не так" . $mysql->error;
  36. }
  37. else{
  38. echo "<script>window.location.href = 'admin_page.php';</script>";
  39. }
  40. $id = $_POST["id_hide"];
  41. ?>
  42. ?>