.navbar.scrolled { background-color: rgba(255, 255, 255, 0.95) !important; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } '; // 导航栏 echo ''; // 为内容添加顶部内边距 echo '
'; session_start(); $error = ''; if (isset($_GET['register_success']) && $_GET['register_success'] == 1) { $success = '注册成功,请登录'; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $loginId = trim($_POST['login_id']); $password = $_POST['password']; if (empty($loginId) || empty($password)) { $error = '邮箱/用户名和密码不能为空'; } else { // 检查数据库连接是否为 MySQLi 对象 if (!($conn instanceof mysqli)) { log_error('数据库连接错误: 连接不是MySQLi实例', __FILE__, __LINE__); $error = '数据库连接错误,请检查配置'; } else { $stmt = $conn->prepare('SELECT id, username, password FROM developers WHERE email = ? OR username = ?'); if (!$stmt) { log_error('登录查询准备失败: ' . $conn->error, __FILE__, __LINE__); $error = '登录时发生错误,请稍后再试'; } else { $stmt->bind_param('ss', $loginId, $loginId); if (!$stmt->execute()) { log_error('登录查询执行失败: ' . $stmt->error, __FILE__, __LINE__); $error = '登录时发生错误,请稍后再试'; } else { $result = $stmt->get_result(); $developer = $result->fetch_assoc(); if ($developer && password_verify($password, $developer['password'])) { $_SESSION['developer_id'] = $developer['id']; $_SESSION['developer_username'] = $developer['username']; // 处理自动登录 if (isset($_POST['remember_me']) && $_POST['remember_me'] === 'on') { $cookie_lifetime = 30 * 24 * 60 * 60; // 30天 $cookie_params = session_get_cookie_params(); setcookie( session_name(), session_id(), time() + $cookie_lifetime, $cookie_params['path'], $cookie_params['domain'], $cookie_params['secure'], $cookie_params['httponly'] ); ini_set('session.gc_maxlifetime', $cookie_lifetime); } header('Location: dashboard.php'); exit; } else { $error = '邮箱/用户名或密码错误'; } } } } } } ?> 开发者登录

开发者登录

还没有账号?注册