显示textarea WP的变量

时间:2015-02-08 23:19:20

标签: php html wordpress

<?php 
    /*
    ...
    */
    add_action( 'init', 'register_shortcode_mail');

    function register_shortcode_mail(){
       add_shortcode('mail-sender', 'mail_sender_function');
    }

    function mail_sender_function(){

        echo "<form name='myForm' method='POST'>
            Subject: <input type='text' name='subject'>
            <textarea rows = '5' cols = '80' name = 'message' form = 'usrform'>
            </textarea>
            <input type = 'Submit' name='btn' value = 'Send'>
        </form>";
        if(isset($_POST['btn'])){
            $sub = $_POST['subject'];
            $mes = $_POST['message'];
            echo "$mes";
        }

    }
?>

您好。我试图在wordpress网站上显示textarea($ mes)的内容,但每当我点击提交btn时,包含一些文本的所有输入框都会自行清除,没有任何回声。

1 个答案:

答案 0 :(得分:0)

替换:  isset($_POST['btn'])$_SERVER["REQUEST_METHOD"] == "POST"