<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用戶信息後臺管理系統</title>
</head>
<!--表格的格式 用css 寫的-->
<style type="text/css">
.wrapper {width: 1000px;margin: 20px auto;}
h2 {text-align: center;}
.add {margin-bottom: 20px;}
.add a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;}
.exit {margin-bottom: 20px;}
.exit a {text-decoration: none;color: #fff;background-color: #800907;padding: 6px;border-radius: 5px;}
td {text-align: center;}
</style>
<body>
<div class="wrapper">
<h2>用戶信息後臺管理系統</h2>
<div class="add">
<a href="enroll.php" target="_blank">添加信息</a> <!--跳轉到註冊頁面-->
</div>
<div class="exit">
<a href="http://baidu.com">退出</a>
</div>
<!-- 在這添加的是查詢的搜索框 根據姓名和手機號進行查詢 -->
<form action="chaxun.php" method="post" name="form2" >
<input name="info" type="text" placeholder="姓名或手機號" />
<input name="Submit" type="submit" value="查詢" /> <!--提交後轉到chaxun.php 進行查詢操作-->
</form>
<br>
<!--表格的信息 -->
<table width="960" border="1" align =''>
<tr>
<th>姓名</th>
<th>性別</th>
<th>愛好</th>
<th>手機號</th>
<th>郵箱</th>
<th>頭像</th>
<th>備註</th>
<th>id</th>
<th>刪除</th>
<th>修改</th>
</tr>
<?php
//連接數據庫
$mysqli = mysqli_connect('localhost','root','3589216','php10');
if (!$mysqli) {
printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;}
mysqli_query($mysqli , "set names utf8");
//查詢數據庫中用戶信息,並顯示在網頁上
$sql = 'select * from msg';
$retval = mysqli_query( $mysqli, $sql );
if(! $retval )
{
die('無法讀取數據: ' . mysqli_error($mysqli));
}
//把記錄循環輸出,否則只會輸出一條
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo "<tr>
<td> {$row['name1']}</td> ".
"<td>{$row['sex']} </td> ".
"<td>{$row['interest']} </td> ".
"<td>{$row['mobile']} </td> ".
"<td>{$row['email']} </td> ".
"<td>{$row['files']} </td> ".
"<td>{$row['remark']} </td> ".
"<td>{$row['id']} </td> ".
"<td><a href='javascript:del({$row['id']})'>刪除</a> </td>".
//彈窗確定<script>標籤 注意連接的.
"<td><a href='change.php?id={$row['id']}'>修改</a> </td>
//連接到change.php
</tr>";
}
?>
</table>
</div>
</body>
<!--要刪除時的彈窗-->
<script type="text/javascript">
function del (id) {
if (confirm("確定刪除這條信息嗎?")){
window.location = "delete.php?id="+id;
/*連接到delete.php --> 連接數據庫 --> 刪除*/
}
}
</script>
</html>
簡單描述下:
一張表格裏面有用戶信息 ,當你點擊確認刪除後,會跳轉到delete.php 進行刪除,然後在返回到後臺的頁面
表格上面會有添加的按鈕,點擊後會跳轉到enroll.php,進行用戶信息的添加
每行上會有一個修改的按鈕 點擊後會跳轉到change.php 中,會展示出像註冊的頁面,但是用戶的信息,會顯示在頁面上,比如選擇的圖像,進行修改在提交
還會有一個查詢的按鈕,根據用戶名和手機號進行查詢,點擊後跳轉chaxun.php