doLtConfig.php 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. $groups = $_POST["groups"];
  3. $channel = $_POST['channel'];
  4. $uid = $_POST['uid'];
  5. $historyId = $_POST['historyId'];
  6. $unicomMallUid = $_POST['unicomMallUid'];
  7. $referer = $_POST['referer'];
  8. $pageKey = $_POST['pageKey'];
  9. include_once("../../untils/conn.php");
  10. if ($con) {
  11. mysqli_query($con, "set names utf8");
  12. $result = $con->query("SELECT * FROM config_api WHERE groups = '" . $groups . "'");
  13. if ($result->num_rows == 0) {
  14. // 数据库中不存在该记录,执行插入操作
  15. $data = $con->query("INSERT INTO config_api (groups, channel, uid, historyId, unicomMallUid, referer, pageKey) VALUES ('" . $groups . "', '" . $channel . "', '" . $uid . "', '" . $historyId . "', '" . $unicomMallUid . "' , '" . $referer . "', '" . $pageKey . "')");
  16. if ($data) {
  17. echo "<script>alert('添加信息');window.location.href='../ltapi.php'</script>";
  18. } else {
  19. echo ("<script>alert('添加失败');window.location.replace(document.referrer)</script>");
  20. }
  21. } else {
  22. // 数据库中存在该记录,执行更新操作
  23. $data = $con->query("UPDATE config_api SET channel = '" . $channel . "', uid = '" . $uid . "', historyId = '" . $historyId . "', unicomMallUid = '" . $unicomMallUid . "', referer = '" . $referer . "', pageKey = '" . $pageKey . "' WHERE groups = '" . $groups . "'");
  24. if ($data) {
  25. echo "<script>alert('修改信息成功');window.location.href='../ltapi.php'</script>";
  26. } else {
  27. echo ("<script>alert('修改失败');window.location.replace(document.referrer)</script>");
  28. }
  29. }
  30. }
  31. $con->close();
  32. ?>