Skip to main content
improved formatting
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

How to redirect to specified page after form was submitted?

Warning: Cannot modify header information - headers already sent by (output started at wordpress\wp-admin\menu-header.php:94) in wordpress\wp-content\plugins\test\test.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at wordpress\wp-admin\menu-header.php:94) in wordpress\wp-content\plugins\test\test.php on line 16

<?php
/*
Plugin Name: TEST
Plugin URI: http://localhost/
Description: TEST
Version: 0.0.1
Author: TEST
Author URI: http://localhost/
*/
add_action('admin_menu', 'test');
function test() { 
    add_menu_page('test', 'test', 0, 'test/test.php', 'page');
} 
function page() {
    if(isset($_POST['submit'])) {
        header('Location: /index.php');
        exit;
    }
    echo '<form action="" method="post"><input type="submit" value="Submit form" name="submit" /></form>';
    var_dump($_POST);
}

How to redirect to specified page after form was submitted?

Warning: Cannot modify header information - headers already sent by (output started at wordpress\wp-admin\menu-header.php:94) in wordpress\wp-content\plugins\test\test.php on line 16

<?php
/*
Plugin Name: TEST
Plugin URI: http://localhost/
Description: TEST
Version: 0.0.1
Author: TEST
Author URI: http://localhost/
*/
add_action('admin_menu', 'test');
function test() { 
    add_menu_page('test', 'test', 0, 'test/test.php', 'page');
} 
function page() {
    if(isset($_POST['submit'])) {
        header('Location: /index.php');
        exit;
    }
    echo '<form action="" method="post"><input type="submit" value="Submit form" name="submit" /></form>';
    var_dump($_POST);
}

How to redirect to specified page after form was submitted?

Warning: Cannot modify header information - headers already sent by (output started at wordpress\wp-admin\menu-header.php:94) in wordpress\wp-content\plugins\test\test.php on line 16

<?php
/*
Plugin Name: TEST
Plugin URI: http://localhost/
Description: TEST
Version: 0.0.1
Author: TEST
Author URI: http://localhost/
*/
add_action('admin_menu', 'test');
function test() { 
    add_menu_page('test', 'test', 0, 'test/test.php', 'page');
} 
function page() {
    if(isset($_POST['submit'])) {
        header('Location: /index.php');
        exit;
    }
    echo '<form action="" method="post"><input type="submit" value="Submit form" name="submit" /></form>';
    var_dump($_POST);
}
Source Link
Sergey L
  • 103
  • 1
  • 2

How to send "Location" header on plugin form submit event?

How to redirect to specified page after form was submitted?

Warning: Cannot modify header information - headers already sent by (output started at wordpress\wp-admin\menu-header.php:94) in wordpress\wp-content\plugins\test\test.php on line 16

<?php
/*
Plugin Name: TEST
Plugin URI: http://localhost/
Description: TEST
Version: 0.0.1
Author: TEST
Author URI: http://localhost/
*/
add_action('admin_menu', 'test');
function test() { 
    add_menu_page('test', 'test', 0, 'test/test.php', 'page');
} 
function page() {
    if(isset($_POST['submit'])) {
        header('Location: /index.php');
        exit;
    }
    echo '<form action="" method="post"><input type="submit" value="Submit form" name="submit" /></form>';
    var_dump($_POST);
}