doFoundation.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. $site_name = $_POST['site_name'];
  3. $site_seo = $_POST['site_seo'];
  4. $site_key = $_POST['site_key'];
  5. $site_ms = $_POST['site_ms'];
  6. $site_icp = $_POST['site_icp'];
  7. $light_logo = $_POST['light_logo'];
  8. $dark_logo = $_POST['dark_logo'];
  9. $reuser = $_POST['reuser'];
  10. $loginuser = $_POST['loginuser'];
  11. $type = $_POST ['type'];
  12. include_once("../../untils/conn.php");
  13. if ($con) {
  14. mysqli_query($con, "set names utf8");
  15. // 查询数据库中的记录数
  16. $result = mysqli_query($con, "SELECT COUNT(*) FROM foundation WHERE type= '$type'");
  17. $row = mysqli_fetch_row($result);
  18. $num_rows = $row[0];
  19. if ($num_rows == 0) {
  20. // 如果记录数为0,说明数据库中没有数据,执行插入新数据的操作
  21. $data = $con->query("INSERT INTO foundation (site_name, site_seo, site_key, site_ms,site_icp, light_logo, dark_logo, reuser , loginuser, type) VALUES ('$site_name', '$site_seo', '$site_key', '$site_ms', '$site_icp', '$light_logo', '$dark_logo', '$reuser' , '$loginuser' , '$type')");
  22. } else {
  23. // 如果记录数不为0,说明数据库中已经存在数据,执行更新操作
  24. $data = $con->query("UPDATE foundation SET site_name='$site_name', site_seo='$site_seo', type='$type', site_key='$site_key', site_ms='$site_ms', site_icp='$site_icp', light_logo='$light_logo', dark_logo='$dark_logo', reuser='$reuser', loginuser='$loginuser' WHERE id=1");
  25. }
  26. if ($data > 0) {
  27. echo "<script>alert('操作成功');window.location.href='../Foundation.php'</script> ";
  28. } else {
  29. echo ("<script>alert('操作失败');window.location.replace(document.referrer)</script>");
  30. // echo "Error updating record: " . $con->error;
  31. }
  32. }
  33. $con->close();
  34. ?>