打印文本区域的内容不起作用

php:

 if(isset($_POST['submit_']))
 {
    if(isset($_POST['textEditor']) && !empty($_POST['textEditor']))
    {
       echo 'hello';
       $msg = $_POST['textEditor'];
       echo ($msg);
    }
 }

html:

 <input type="submit" name="submit_" value="Add" />
 <textarea name="textEditor" rows="20" cols="60" > </textarea>

I want to print the content of the text area when submit button is clicked. But even when the textarea is non-empty, it prints nothing.

For testing, I printed 'hello', but it still prints nothing that is the second ' if ' statement is not satisfied. I do not understand why does the second ' if ' statement fail !

And if I remove the second if statement, then I get an error:

Notice: Undefined index: textEditor in...

seems you have texteditor outside of form you need to try like

<?php
if(isset($_POST['submit_']))
 {
    if(isset($_POST['textEditor']) && !empty($_POST['textEditor']))
    {
       echo 'hello';
       $msg = $_POST['textEditor'];
       echo ($msg);
    }
 }
?>
<form method="post">
<textarea name="textEditor" rows="20" cols="60" > </textarea>
<input type="submit" name="submit_" value="Add" />
</form>

if form is set already try to check form method="post" or print_r($_POST); in php code

Might be debugging the code will help you. as put this code under if(isset($POST['submit'])) { line

echo "<pre>";
print_r($_POST);
echo "</pre>";

hope this helps.

Try this:

<html>
<?php
    if(isset($_POST['submit_']))
 {
    if(isset($_POST['textEditor']) && !empty($_POST['textEditor']))
    {
       echo 'hello';
       $msg = $_POST['textEditor'];
       echo ($msg);
    }
 }
?>
<head>



</head>
<body>
    <form name="myForm" method="post">

        <textarea name="textEditor" rows="20" cols="60" > </textarea>
        <input type="submit" name="submit_" value="Add" />
    </form>
</body>
</html>

Hope it helps