title: Am I taking the right approach in PHP OOP?
body: <p>Trying to make the switch over to OOP PHP as opposed to my current approach of having a whole load of PHP code in all of my pages.</p>
  
  <p>I've thrown something together which takes a post title, content and status and stores it in a simple database.</p>
  
  <p>I just want to know if I have the right idea or if I'm way off - is it worth me carrying on taking this approach on it?</p>
  
  <pre><code>&lt;?php
  
  $conn = new mysqli('127.0.0.1','root','','admin');
  
  class post {
      private $title;
      private $content;
      private $status;
      private $errors;
      private $check;
  
      function __construct(){
          if(isset($_POST) &amp;&amp; !empty($_POST)){
  
              if(empty($_POST['title'])){
                  $this-&gt;errors[] = "Title is required";
              }
  
              if(empty($_POST['content'])){
                  $this-&gt;errors[] = "Content is required";
              }
  
              if(empty($_POST['status'])){
                  $this-&gt;errors[] = "Status is required";
              }
  
              if(empty($this-&gt;errors)){
                  $this-&gt;title = $_POST['title'];
                  $this-&gt;content = $_POST['content'];
                  $this-&gt;status = $_POST['status'];
                  $this-&gt;check = true;
              } else {
                  echo "&lt;pre&gt;";
                  var_dump($this-&gt;errors);
                  echo "&lt;/pre&gt;";
              }
          }
      }
  
      function submit(){
          if($this-&gt;check){
              global $conn;
  
              if($conn-&gt;connect_error){
                  die("Connection error: " . $conn-&gt;connect_error);
              };
  
              $stmt = $conn-&gt;prepare("INSERT INTO posts (title, content, status) VALUES (?, ?, ?)");
  
              $stmt-&gt;bind_param('sss', $this-&gt;title, $this-&gt;content, $this-&gt;status);
  
              if($stmt-&gt;execute()){
                  echo "Post added succesfully";
              } else {
                  echo "&lt;pre&gt;";
                  var_dump($stmt);
                  echo "&lt;/pre&gt;";
              }
  
          };
      }
  };
  
  ?&gt;
  </code></pre>