index.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // 确保没有其他 PHP 逻辑会导致页面重定向
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <title>欠款查询系统</title>
  8. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
  9. <link rel="stylesheet" type="text/css" href="css/styles.css">
  10. </head>
  11. <body>
  12. <div class="container">
  13. <h1>欠款查询系统</h1>
  14. <form id="searchForm">
  15. <input type="text" id="debtorName" name="debtorName" placeholder="请输入姓名" class="search-bar" required>
  16. <button type="button" onclick="searchDebt()" class="button">查询</button>
  17. <!-- 新增记录按钮 -->
  18. <button type="button" id="addRecordBtn" class="button">新增记录</button>
  19. </form>
  20. <div id="result" class="result"></div>
  21. </div>
  22. <script>
  23. function searchDebt() {
  24. const debtorName = document.getElementById('debtorName').value;
  25. fetch(`search.php?debtorName=${encodeURIComponent(debtorName)}`)
  26. .then(response => response.text())
  27. .then(data => document.getElementById('result').innerHTML = data)
  28. .catch(error => console.error('查询出错:', error));
  29. }
  30. document.getElementById('addRecordBtn').addEventListener('click', function() {
  31. const password = prompt('请输入密码:');
  32. if (password === 'uKPAYkIZ2cFlKPN[') { // 使用数据库管理密码
  33. window.location.href = 'add_record.php';
  34. } else {
  35. alert('密码错误');
  36. }
  37. });
  38. </script>
  39. </body>
  40. </html>