美文网首页
编辑和删除留言

编辑和删除留言

作者: sky枫 | 来源:发表于2018-06-05 17:22 被阅读0次
  • 先看下效果图


    301.PNG
  • 这里设定的是只能删除和编译自己的留言
    单击编辑进入编辑页面,然后开始编辑留言


    302.PNG
303.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="添加留言">&nbsp;&nbsp;
            <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>";
?>

相关文章

  • 编辑和删除留言

    先看下效果图301.PNG 这里设定的是只能删除和编译自己的留言单击编辑进入编辑页面,然后开始编辑留言302.PN...

  • php学习-简易留言板

    ①首页: ②增加留言: ③编辑留言: ④删除留言:

  • 左滑编辑/删除效果

    说明 此文梳理模仿QQ好友列表项左滑编辑/删除效果。 需求 初始隐藏编辑/删除按钮编辑和删除按钮宽度相同 左滑显示...

  • 编辑老师留言

    五岳寻仙不辞远,终于等来大神仙。 樵夫传来一声唤,难道这是灵台山。

  • mac pdf编辑和删除

    https://support.apple.com/zh-cn/HT202945[https://support....

  • UITableView 编辑状态(删除、添加、移动)

    ----- TableView 删除和添加 ----- 开启编辑状态 //1.让 tableView 处于编辑状...

  • 2019-02-03

    在除夕前夜,一阵心酸和委屈淹没了她,翻遍通讯录找不到可以倾诉的朋友,编辑好的信息删除了,再编辑,再删除,再编辑……...

  • ztree实现编辑和删除功能

    前面写了一篇ztree实现根节点单击事件,显示节点信息https://www.jianshu.com/p/1e0c...

  • day08 删除和编辑

    删除 urls.py views.py art.html 编辑 urls.py views.py Artform....

  • 13.4鉴定和许可

    当前API对于编辑和删除没有任何限制,我们希望做些:

网友评论

      本文标题:编辑和删除留言

      本文链接:https://www.haomeiwen.com/subject/yqhmsftx.html