编辑和删除留言

2018-06-05  本文已影响0人  sky枫
303.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是我(留言板主页的名字)
  
}
?>
<!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>
<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);
?>
<?php session_start(); ?>
<meta charset="utf-8">
<?php 
$_SESSION = array();
session_destroy();
echo "<script>alert('注销成功') </script>";
echo "<script> window.localhost.href='denglu.php'</script>";
?>
上一篇下一篇

猜你喜欢

热点阅读