doBan.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. $banner = $_POST['banner'];
  3. $link = $_POST['link'];
  4. $banner_one = $_POST['banner_one'];
  5. $link_one = $_POST['link_one'];
  6. $banner_two = $_POST['banner_two'];
  7. $link_two = $_POST['link_two'];
  8. $type = 'banner';
  9. include_once("../../untils/conn.php");
  10. if ($con) {
  11. mysqli_query($con, "set names utf8");
  12. // 查询数据库中的记录数
  13. $result = mysqli_query($con, "SELECT COUNT(*) FROM system WHERE id=1");
  14. $row = mysqli_fetch_row($result);
  15. $num_rows = $row[0];
  16. if ($num_rows == 0) {
  17. // 如果记录数为0,说明数据库中没有数据,执行插入新数据的操作
  18. $data = $con->query("INSERT INTO system (banner, link, type, banner_one, link_one, banner_two, link_two) VALUES ('$banner', '$link', '$type', '$banner_one', '$link_one', '$banner_two', '$link_two')");
  19. } else {
  20. // 如果记录数不为0,说明数据库中已经存在数据,执行更新操作
  21. $data = $con->query("UPDATE system SET banner='$banner', link='$link', type='$type', banner_one='$banner_one', link_one='$link_one', banner_two='$banner_two', link_two='$link_two' WHERE id=1");
  22. }
  23. if ($data > 0) {
  24. echo "<script>alert('修改成功');window.location.href='../Bansytem.php'</script> ";
  25. } else {
  26. echo ("<script>alert('修改失败');window.location.replace(document.referrer)</script>");
  27. }
  28. }
  29. $con->close();
  30. ?>