-
先看下效果图
301.PNG
-
这里设定的是只能删除和编译自己的留言
单击编辑进入编辑页面,然后开始编辑留言
302.PNG
-
删除留言 直接点击删除就行
304.PNG
下面是源代码
- 编辑
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body background="6.jpg">
<?php
include "my.php";
$uid=$_GET["mid"];
$sql1 = "select * from message where id = '$uid'";
$result1= mysqli_query($conn,$sql1); #到数据库中执行sql1语句
$persion = mysqli_fetch_array($result1); #查询到的结果取出一行赋值给$persion
?>
<form method="post" >
<table>
<tr>
<td>
<h1>编辑留言</h1>
</td>
</tr>
<tr>
<td>
<textarea name="content" rows="10" cols="80"> <?php echo $persion["content"]; ?></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="添加留言">
<input type="reset" name="reset" value="重置">
</td>
</tr>
</table>
</form>
<?php
$uid=$_GET["mid"];
if(isset($_POST["submit"])) {
$content = $_POST["content"];
$sql = "update message set content = '$content' where id = '$uid' ";
$result = mysqli_query($conn,$sql);
if($result){
echo "<script>alert('编辑成功!')</script>";
echo "<script>window.location.href='ly.php'</script>"; ##ly.php是我(留言板主页的名字)
}
else{
echo "编辑失败!";
}
}
?>
</body>
</html>
- 删除
<?php
include "my.php";
$uid = $_GET["mid"];
$sql = " delete from message where id = $uid ";
$result = mysqli_query($conn,$sql);
if($result){
echo "<script>alert('留言删除成功!')</script>";
echo "<script>window.location.href='ly.php'</script>";##ly.php是我(留言板主页的名字)
}
?>
-
下面是个人中心页面
点击“个人中心”就会转跳
305.PNG
306.PNG -
这个人中心这里 我只设置了一个功能能就是头像上传
这是截图
307.PNG
308.PNG
下面是代码部分
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body background="3.jpg">
<?php
require 'my.php';
$uid = $_GET["uid"];
$sql = "select * from user where uid = $uid";
$result = mysqli_query($conn,$sql);
$person = mysqli_fetch_array($result);
?>
<center>
<form action="upload.php" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="8">
<tr>
<td colspan="2" align="center" ><img src="<?php echo $person['picture']; ?>" width="150" higth=110></td>
<td colspan="2"><input type="file" name="file"><input type="submit" name="submit" value="提交" style="width:100px;height:30px"></td>
<input type="hidden" name="uid" value="<?php echo $uid;?>" ></td>
</tr>
<tr>
<td align="right" size="6">用户名</td>
<td><?php echo $person["username"]; ?></td>
</tr>
<tr>
<td align="right" size="6">邮箱</td>
<td><?php echo $person["email"]; ?></td>
</tr>
<tr>
<td align="right"size="6">性别</td>
<td><?php echo $person["sex"]; ?></td>
</tr>
<tr>
<td align="right" size="6">注册时间</td>
<td><?php echo $person["time"]; ?></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- upload.php
<meta charset="utf-8">
<?php
include "my.php";
//echo $_FILES['file']['name'] . "<br/>";
//echo $_FILES['file']['type'] . "<br/>";
//echo $_FILES['file']['tmp_name'] . "<br/>";
//echo $_FILES['file']['size'] . "<br/>";
//echo $_FILES['file']['error'] . "<br/>";
$path = "./image/"; #设置存放路径
$uid = $_POST["uid"];
if (!is_dir($path))
{
mkdir($path);
}
$mime = $_FILES['file']['type']; #$_FILES函数
if (($mime == "image/jpeg") || ($mime == "image/gif") || ($mime == "image/png") && ($_FILES['file']['error'] == 0))
{
$filename = $path . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $filename);
$sql = "update user set picture = '$filename' where uid = $uid";
$result = mysqli_query($conn,$sql);
if ($result)
{
echo "<script>alert('头像上传成功!')</script>";
echo "<script>window.location.href=\"percenter.php?uid=$uid\"</script>";#跳转到个人中心页面
}
}
else
{
echo "<script>alert('头像上传失败!请重试!')</script>";
echo "<script>window.location.href=\"percenter.php?uid=$uid\"</script>";
}
mysqli_close($conn);
?>
-
最后还有一个推出功能
305.PNG
点击退出跳转到登陆页面
309.PNG - 代码
<?php session_start(); ?>
<meta charset="utf-8">
<?php
$_SESSION = array();
session_destroy();
echo "<script>alert('注销成功') </script>";
echo "<script> window.localhost.href='denglu.php'</script>";
?>
网友评论