PHP:在类中使用isset()函数

I am into procedural programming and new to OOP. With the following code, I would like to print a message "Submitted successfully" on clicking submit button. But it is not happening. In the procedural programming I do something like isset($_POST[$name]). Here how to refer button name?

<?php

//myclass

class InsertData {
    public $txtwidth;
    public $txtheight;
    public $txtname;
    public $btnwidth;
    public $btnheight;
    public $btnname;

    function setTextField($tw, $th, $tname) {
        $this->txtwidth = $tw;
        $this->txtheight =$th;
        $this->txtname = $tname;        
    }

    function setButton($bw, $bh, $bname) {
        $this->btnwidth = $bw;
        $this->btnheight =$bh;
        $this->btnname = $bname;
    }

function displayText() {
    if(isset($_POST[$this->btnname])) {         
            echo "Submitted successfully";
        }
}
    function getTextField() {
        $str = "<form name='inputform' action='#' method='post'>
        <input type='text' name='".$this->txtname."' Style=width:".$this->txtwidth."px;height:".$this->txtheight."px><br><br>
         <input type='submit' name='".$this->btnwidth."' Style=width:".$this->btnheight."px;height:".$this->btnname."px>
         </form>";  


        return $str;
    }

}
?>

My code

<?php

//my code

include "InsertData.php";
$txt = new InsertData();

$txt->setTextField(800,200,'yourname');
$txt->setButton(100, 200, 'click');
echo $txt->getTextField();
echo $txt->displayText();
?>

Just modify function displayText() to

function displayText() {
  return "Submitted successfully";
}

And on submit do a ,

if(isset($_POST['your_btn_name'])) {   
  echo  $txt->displayText();    
}

check this function you exchange the value of width,name and height

function getTextField() {
        $str = "<form name='inputform' action='#' method='post'>
        <input type='text' name='".$this->txtname."' Style=width:".$this->txtwidth."px;height:".$this->txtheight."px><br><br>
         <input type='submit' name='".$this->btnname."' Style=width:".$this->btnwidth."px;height:".$this->btnheight."px>
         </form>";  


        return $str;
    }

Try passing it as a parameter to the classes function, for example:

<?php
class Foo
{
    public function showMessage($message = '')
    {
        if ($message != '')
        {
            print "You submitted: {$message}";    
            return;    
        }
        print "Message failed to send...";
        return;
    }
}

$foo = new Foo();
?>
<form action="#" method="post">
    <input type="text" name="message" />
    <br />
    <input type="submit" name="submit" value="Submit my message!" />
</form>
<?php
if (isset($_POST['submit']))
{
    $foo->showMessage($_POST['message']);
}

And without a message, it says: Message failed to send...
And with a message it says: You submitted: message (I used the message of message)