Proxy_upstate.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. session_start();
  3. include_once("../../untils/conn.php");
  4. mysqli_query($con, "set names utf8");
  5. $spid = $_GET['id'];
  6. $puid = $_GET['puid'];
  7. $status = $_GET['status'];
  8. // 查询数据库中是否存在对应的记录
  9. $sql = "SELECT * FROM goodsta WHERE spid=$spid AND puid=$puid";
  10. $result = mysqli_query($con, $sql);
  11. if (mysqli_num_rows($result) == 0) {
  12. // 如果不存在则插入新的记录
  13. $sql = "INSERT INTO goodsta (spid, puid, status) VALUES ($spid, $puid, $status)";
  14. if (mysqli_query($con, $sql)) {
  15. echo "<script>alert('操作成功');window.location.href='../Goods.php';</script>";
  16. } else {
  17. echo "<script>alert('操作太快啦,请稍后刷新再试!');window.location.href='../Goods.php';</script>";
  18. }
  19. } else {
  20. // 如果存在则更新记录
  21. $sql = "UPDATE goodsta SET status=$status WHERE spid=$spid AND puid=$puid";
  22. if (mysqli_query($con, $sql)) {
  23. echo "<script>alert('操作成功');window.location.href='../Goods.php';</script>";
  24. } else {
  25. echo "<script>alert('操作太快啦,请稍后刷新再试!');window.location.href='../Goods.php';</script>";
  26. }
  27. }
  28. mysqli_close($con);
  29. ?>