Member Information
connect_error) {
die("连接失败: " . $conn->connect_error);
}
?>
Existing Members
query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "姓名: " . $row["CName"]. " - 生日: " . $row["Bdate"]. "
";
}
} else {
echo "没有结果";
}
?>
Register a New Member
connect_error) {
die("连接失败: " . $conn->connect_error);
}
$cname = $_POST["Cname"];
$phoneNumber = $_POST["PhoneNumber"];
$iAccount = $_POST["iAccount"];
$iPassword = $_POST["iPassword"];
$bdate = $_POST["Bdate"];
// 检查是否已经存在相同记录
$check_sql = "SELECT * FROM Members WHERE iAccount = '$iAccount' AND PhoneNumber = '$PhoneNumber'";
$check_result = $conn->query($check_sql);
if ($check_result->num_rows > 0) {
echo "如果已存在相同的账号和电话号码组合,无法注册。";
} else {
// 执行插入操作
$sql = "INSERT INTO Members (CName, PhoneNumber, iAccount, iPassword, Bdate) VALUES ('$Cname', '$PhoneNumber', '$iAccount', '$iPassword', '$Bdate')";
if ($conn->query($sql) === TRUE) {
echo "注册成功";
} else {
echo "注册时发生错误: " . $conn->error;
}
}
// 关闭数据库连接
$conn->close();
}
?>