Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除后php源代码_Php_Post_Comments - Fatal编程技术网

删除后php源代码

删除后php源代码,php,post,comments,Php,Post,Comments,我需要帮助。我已经创建了发布系统。我现在需要创建删除系统。我只需要把系统,将删除特定的职位,有人需要删除。这是我的邮寄系统 if(empty($_POST) === false){ $status_data = array( 'status' => $_POST['status'], 'status_poster' => $_SESSION['user_id'], 'date' => date('Y-m-d H:i:s') ); update_s

我需要帮助。我已经创建了发布系统。我现在需要创建删除系统。我只需要把系统,将删除特定的职位,有人需要删除。这是我的邮寄系统

if(empty($_POST) === false){
 $status_data = array(
   'status' => $_POST['status'],
   'status_poster' => $_SESSION['user_id'],
   'date' => date('Y-m-d H:i:s')
   );
   update_status($id, $status_data, $user_id);
  }  
   if($profile_data['user_id']){

     ?>
        <form action="" method="post">
        <div class="field">
    <label for="Status" style="color: #7f7f7f; font-family: Cambria, Hoefler Text, Liberation Serif, Times, Times New Roman, serif;"></label>
    <textarea rows="4" cols="50" name="status"placeholder="say something" id="status_area" ></textarea>
    <div id="button">
    <input name="user_status" type="submit" value="Post">
    </div>
    </div>
       </form>
       </div>
       <div id="status">
        <?php
    if($_Get['delete']){
   $id = $_GET['delete'];
    $sql = "DELETE FROM status WHERE id='$id'";
    $res = mysql_query($sql) or die(mysql_error());
    echo"<meta http-equiv = 'refresh' content =' 0;url=index.php'>";
    }
      ?>
     <?php
    }
    if(user_exists($username) === true){
$user_id         = user_id_from_username($username);
$profile_data    = user_data($user_id, 'first_name', 'last_name', 'user_id');

    $find_post = mysql_query("SELECT * FROM status ORDER BY date DESC");
    while($rows = mysql_fetch_assoc($find_post)){
$post_id = $rows['id'];
$first_name = $profile_data['first_name'];
$last_name = $profile_data['last_name'];
$username = $profile_data['username'];
$user = $user_data['user_id'];
$data = $rows['date'];
$post_name = $rows['status_poster'];
$post = $rows['status'];
    if( $user_id === $post_name){
    ?>

    <div class='holder'>
   <div class='holder_half'>
   <?php
echo '<div id="picture">
<img src="', $profile_data['profile_picture'], '" alt="', $profile_data['first_name'],'\'s Profile image">';
echo "
</div>
<div class='ten'>
<div id='statusname'><a href='#'>$first_name $last_name</a></div>
<div class='date_time'>posted at $data</div>
<span class='span' data-ft='{&quot;tn&quot;:&quot;K&quot;}'>
<div id='statustext'>$post</div>
</span>
</div>
</div>
<textarea rows='4' cols='50' id='comment' name='comment' placeholder='' id='status_area' ></textarea>
</div>
";
        }
    }
 }
   }
   ?>   
   </div>
    </div>if(empty($_POST) === false){
$status_data = array(
'status' => $_POST['status'],
'status_poster' => $_SESSION['user_id'],
'date' => date('Y-m-d H:i:s')
);
update_status($id, $status_data, $user_id);
    }
   if($profile_data['user_id']){
      ?>
     <form action="" method="post">
<div class="field">
    <label for="Status" style="color: #7f7f7f; font-family: Cambria, Hoefler Text, Liberation Serif, Times, Times New Roman, serif;"></label>
    <textarea rows="4" cols="50" name="status"placeholder="say something" id="status_area" ></textarea>
    <div id="button">
    <input name="user_status" type="submit" value="Post">
    </div>
 </div>
    </form>
   </div>
   <div id="status">
   <?php
   if($_Get['delete']){
$id = $_GET['delete'];
$sql = "DELETE FROM status WHERE id='$id'";
$res = mysql_query($sql) or die(mysql_error());
echo"<meta http-equiv = 'refresh' content =' 0;url=index.php'>";
   }
    ?>
      <?php
        }
   if(user_exists($username) === true){
$user_id         = user_id_from_username($username);
$profile_data    = user_data($user_id, 'first_name', 'last_name', 'user_id');

    $find_post = mysql_query("SELECT * FROM status ORDER BY date DESC");
    while($rows = mysql_fetch_assoc($find_post)){
$post_id = $rows['id'];
$first_name = $profile_data['first_name'];
$last_name = $profile_data['last_name'];
$username = $profile_data['username'];
$user = $user_data['user_id'];
$data = $rows['date'];
$post_name = $rows['status_poster'];
$post = $rows['status'];
    if( $user_id === $post_name){
    ?>
     <div class='holder'>
     <div class='holder_half'>
      <?php
echo '<div id="picture">
<img src="', $profile_data['profile_picture'], '" alt="', $profile_data['first_name'],'\'s Profile image">';
echo "
</div>
<div class='ten'>
<div id='statusname'><a href=''>$first_name $last_name</a></div>
<div class='date_time'>posted at $data</div>
<span class='span' data-ft='{&quot;tn&quot;:&quot;K&quot;}'>
<div id='statustext'>$post</div>
</span>
</div>
</div>
<textarea rows='4' cols='50' id='comment' name='comment' placeholder='' id='status_area' ></textarea>
</div>
  ";
        }
    }
}
      }
    ?>  
     </div>
    </div>
if(空($\u POST)==false){
$status\u data=array(
'status'=>$\u POST['status'],
'status\u poster'=>$\u SESSION['user\u id'],
'日期'=>日期('Y-m-d H:i:s')
);
更新用户状态($id、$status\u data、$user\u id);
}  
if($profile_data['user_id'])){
?>

我在代码中看到2个删除查询,但您正在询问如何创建一个。以下是mysqli prepared statements版本(防止sql注入)

删除…我不确定你是在单独的页面上进行删除,也就是说你点击帖子,它会将你带到第二页,在那里你会看到删除按钮,还是[在同一页上]通过选中每个帖子的复选框来删除帖子。如果您使用第一种方法,下面的代码将删除它,但首先您需要通过url(如单击)将id传递到第二页

$id = $_GET['id']

$stmt = $database->prepare("DELETE from status where id = ?");
$stmt->bind_param('i', $id);//you could put 's' if the id contains other than numbers
$stmt->execute();

这将删除id匹配的帖子。

我喜欢下面那些花括号,看起来像拱廊videogame@DamienPirsy是的。我喜欢它。
$\u Get['delete']
$\u Get['delete']
@FerozAkbar我已将它更改为$\u Get['delete'],但没有工作。您如何调用删除操作?
$id = $_GET['id']

$stmt = $database->prepare("DELETE from status where id = ?");
$stmt->bind_param('i', $id);//you could put 's' if the id contains other than numbers
$stmt->execute();