title: PHP: Using isset() function inside the class
body: <p>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?</p>
  
  <pre><code>&lt;?php
  
  //myclass
  
  class InsertData {
      public $txtwidth;
      public $txtheight;
      public $txtname;
      public $btnwidth;
      public $btnheight;
      public $btnname;
  
      function setTextField($tw, $th, $tname) {
          $this-&gt;txtwidth = $tw;
          $this-&gt;txtheight =$th;
          $this-&gt;txtname = $tname;        
      }
  
      function setButton($bw, $bh, $bname) {
          $this-&gt;btnwidth = $bw;
          $this-&gt;btnheight =$bh;
          $this-&gt;btnname = $bname;
      }
  
  function displayText() {
      if(isset($_POST[$this-&gt;btnname])) {         
              echo "Submitted successfully";
          }
  }
      function getTextField() {
          $str = "&lt;form name='inputform' action='#' method='post'&gt;
          &lt;input type='text' name='".$this-&gt;txtname."' Style=width:".$this-&gt;txtwidth."px;height:".$this-&gt;txtheight."px&gt;&lt;br&gt;&lt;br&gt;
           &lt;input type='submit' name='".$this-&gt;btnwidth."' Style=width:".$this-&gt;btnheight."px;height:".$this-&gt;btnname."px&gt;
           &lt;/form&gt;";  
  
  
          return $str;
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>My code   </p>
  
  <pre><code>&lt;?php
  
  //my code
  
  include "InsertData.php";
  $txt = new InsertData();
  
  $txt-&gt;setTextField(800,200,'yourname');
  $txt-&gt;setButton(100, 200, 'click');
  echo $txt-&gt;getTextField();
  echo $txt-&gt;displayText();
  ?&gt;
  </code></pre>