0

我写成

<?php
  if (isset($_POST['delete'])):
    $size = count($_POST['checkbox']);
    for ($i=0; $i<=$size-1; $i++) {
    $id = $_POST['checkbox'][$i];
    $wpdb->query("DELETE FROM wp_submitted_form WHERE id =".$id);
    }
   header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
  endif; 
?>

单击提交按钮时,它会抛出错误消息:

Cannot modify header information - headers already sent by (output started at /home/wizcorea/public_html/wp-admin/includes/template.php:1657) in /home/wizcorea/public_html/wp-content/plugins/submitted-form/view.php on line 54

我希望在单击提交按钮后刷新该页面

4

1 回答 1

0

使用ob_flushPHP的功能。在代码顶部添加此函数。

<?php

ob_flush();

这将起作用。

编辑:

而不是这段代码:

header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

使用此代码:

echo '<script>location.href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"</script>';
于 2013-08-07T10:04:10.343 回答