【php开源代码栏目提醒】:网学会员--在 php开源代码编辑为广大网友搜集整理了:register_result.php绩等信息,祝愿广大网友取得需要的信息,参考学习。
<?php
require_once('common.php'); // 引入公共文件,其中实现了SQL注入漏没检查的代码
// 获取用户名
$username = trim($_GET['uid']);
if(empty($username)) {
echo 'URL参数错误!';
exit;
}
// 调用mysqli的构造函数建立连接,同时选择使用数据库'test'
$db = @new mysqli("127.0.0.1", "developer", "123456", "test");
// 检查数据库连接
if (mysqli_connect_errno()) {
echo "数据库连接失败!<br>\n";
echo mysqli_connect_error();
exit; // 退出程序,后面的所有语句将不再执行
}
// 构造SQL语句查询t_user表
$sql = "SELECT * FROM t_user WHERE f_username='$username'";
$rs = $db->query($sql);
if (!$rs) {
$db->close(); // 关闭数据库连接
echo '查询失败!';
exit;
}
// 从结果记录集中获取记录放入$user数组
$user = $rs->fetch_assoc();
// 关闭数据库连接
$db->close();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Registered Result</title>
<style type="text/css">
<!--
/* 表边框为内凹型 */
table {border-color: #c0e0c0; border-style: inset; border-width:4px;}
td {font-size:14pt}
/* 居中 */
td.hint {color:red; font-size: 20pt;text-align:center}
/* 背景为天蓝色 */
td.caption {background-color:skyblue;font-size: 16pt}
/* 粗体 */
td.label {font-weight:bold;}
-->
</style>
</head>
<body>
<center>
<?php
if (!empty($user) ) { ?>
<table border='0' cellpadding='5' cellspacing='5'>
<tr><td colspan='2' class='hint'>恭喜您注册成功! </td></tr>
<tr><td colspan='2' class='caption'>您的注册信息如下: </td></tr>
<tr><td class='label'>用户名:</td><td><?echo $user['f_username']; ?></td></tr>
<tr><td class='label'>:</td><td><?echo $user['f_name']; ?></td></tr>
<tr><td class='label'>Email:</td><td><?echo $user['f_email'];?></td></tr>
</table>
<?php
} ?>
</center>
</body>
</html>