<?php header('Content-Type: text/html; charset=utf-8');
$db_host = '127.0.0.1'; $db_admin = 'root'; $db_passwd = 'root'; $db_name = 'cms';
$link = mysqli_connect($db_host, $db_admin, $db_passwd, $db_name); $post_id = $_POST['account']; $post_user = $_POST['name']; $post_passwd = $_POST['password'];
if ($post_id == null || $post_user == null || $post_passwd == null) { exit('请勿输入空数据'); }
$select_id = 'SELECT * FROM USER WHERE id = ' . $post_id; $result1 = mysqli_query($link, $select_id); $row_count = mysqli_num_rows($result1); if ($row_count === 1) { exit('账号id重复,请返回重新注册!'); }
$insert_data = "INSERT INTO USER (id, username, password) VALUE($post_id, $post_user, $post_passwd)"; if (!mysqli_query($link, $insert_data)) { echo "no" . "<br>" . mysqli_error($link); } else { mysqli_close($link); header("Location: success.html"); } ?>
<!--success.html--> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="UTF-8"> <title>页面跳转中...</title> <meta http-equiv="refresh" content="5; url=work.html"> </head> <body> <h1>注册成功!</h1> <p>页面将在 <span id="countdown">5</span> 秒后自动跳转...</p> <script> // 添加倒计时效果 let seconds = 5; const countdownElement = document.getElementById('countdown'); const timer = setInterval(() => { seconds--; countdownElement.textContent = seconds; if (seconds <= 0) { clearInterval(timer); } }, 1000); </script> </body> </html>
|