如何从php中的textarea获取文本? [关闭]

I have seen many question are here, but I can not get the answer from that. so I have type the question again here. In a same page how can I get the textarea value.

My code is like this -

<?php
    $action = $_REQUEST['action'];
    $text =$_GET['text'];
    if(!$action){
        $device=file("abc.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        $lines =implode("
",$device);
        echo "<form method='post' action='config.php'>";
        echo "<textarea name='text'  cols='40' rows='15'>$lines</textarea>";
        echo '<td> <input type="submit" name="submit" value="Submit"> </td></form>';
    }


    if($action == "submit" ){
    $ids = explode("
", str_replace("", "", $input));
        echo $ids ;
    }
?>

You trying $_GET to get value of textarea but in form you are using post method.

Try

<?php
$action = $_POST['submit'];
$text = $_POST['text'];
if(!$action)
{
    $device=file("abc.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $lines =implode("
",$device);

    echo "<form method='post' action='config.php'>";
    echo "<textarea name='text'  cols='40' rows='15'>$lines</textarea>";
    echo '<td> <input type="submit" name="submit" value="Submit"> </td></form>';
}

if($action == "submit" )
{
    $ids = explode("
", str_replace("", "", $text));
    echo $ids ; 
}

FINAL UPDATE

<?php
if(isset($_POST['submit']))
{   
    $text = $_POST['text'];
    $ids = explode("
", str_replace("", "", $text));
    echo $ids ; 
}
else
{
    $device = file("abc.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $lines = implode("
",$device);

    echo "<form method='post' action='config.php'>";
    echo "<textarea name='text' cols='40' rows='15'>$lines</textarea>";
    echo '<td><input type="submit" name="submit" value="Submit"> </td></form>';
}

If you send your form with the POST method - the value of "text" will be present in the $_POST array as $_POST['text']

If you send your form with method GET - it will be send over with the URL and can be fetched as $_GET['text'].