Table not to Display

Table not to Display
0

Hallo , sorry about my English , my knowledge about PHP is very sample…

I have these Code for my Comment to Administrate on my Database,

<?php


class ClassProveContakt1 
{
      private $dbHost = 'localhost'; # Host der Datenbank
	  private $dbName = 'meine';      # Name der Datenbank
	  private $dbUser = 'root';      # Name phpmyadmin
	  private $dbPass = 'pass';      # Passwort

      
      private $Name;
      private $Email;
      private $Message;
      private $PostOK;
      private $datetime;
      private $items;
      private $ip; 

   
    function __construct() 
    {

         $this -> ip = $_SERVER['REMOTE_ADDR'];
         $this -> DateTime = date('m/d/Y h:i:s a');  
         $this -> items = ['Name', 'Email', 'Message']; 
          
         $flag = true;
          foreach ( $this -> items as $key ) {  
			           if ( empty ( $_POST[$key] ) )  {
			             $flag = false;    
			           } else {    
			             $this -> $key = trim( filter_var( $_POST[$key], FILTER_SANITIZE_STRING ) );
			            }    
		   }	     
         $this -> PostOK = $flag; 
    }
  
 
    

  
    function ShowForm() 
    {
?>
      <form  method="POST">
        <br>
        <label for="name"><b>Name * </b></label>
        <input type="text" id="name" name="Name" value="">
        <label for="email"><b>E-mail * </b></label>
        <input type="email" id="email" name="Email" value="">
        <br><br>
        <label><b> Message * </b><br>
           <textarea cols="45" rows="6" id="text" name="Message"></textarea>      
        </label>
        <br><br>
        <input  type="submit" name="post" value="POST COMMENT" id="comment">
        <br> 
      </form>
<?php
    }
    function PostOkT() 
    {
        if (isset($_POST['post']))
        {
            $this -> PostNewComment();
        }     
        else if (isset($_POST['delete']))
        {
            $this -> DeleteComment($_POST['delete']);
        }
    }

    function PostNewComment()
    {
        if (! $this -> PostOK)
        {
            echo '<br><div class="msg">*** Please enter all required fields ***</div>';   
        } 
       $this->writeCommentToDatabase(); 
       $this->displayMessages();        
    }

    function displayMessages()
    {
        $messages = $this->getMessages();
?>
   <form method="POST">        
<?php
        foreach ($messages as $message):
?>
     <article>
       <br>
       <p><strong>From: </strong> <?= htmlspecialchars($message['name'])?>
       <strong>At: </strong> <?= $message['datetime'] ?></p>
       <p><?= $message['message'] ?></p>
       <hr>
       
     </article>
<?php
        endforeach;                 
?>
   </form>
<?php
    }

    function DeleteComment($id)
    {
        echo "<br>Lösche jetzt Kommentar $id<br>";
        $this->displayMessages();
    }
     function writeCommentToDatabase()
     {
      // Establish connection with MYSQL Server
      try
      {
         $db = new PDO("mysql:host=localhost;dbname=meine", "root", "pass");
      }
      catch (PDOException $pe)
      {
         echo "<br>Cannot connect to database: " . $pe->getMessage();
         return false;
      }

      //Prepare Query of SQL
      $statement = $db->prepare("INSERT INTO mela(name, email, message, datetime, ip) VALUES (:name, :email, :message, :date, :ip)");
      if (!$statement)
      {
         echo "<br><br>prepare failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($db->errorInfo(), true) . "</p>";
         $ok = FALSE;
      }
      else
      {
         $ok = $statement->bindValue(':name', $this->Name, PDO::PARAM_STR)
            && $statement->bindValue(':email', $this->Email, PDO::PARAM_STR)
            && $statement->bindValue(':message', $this->Message, PDO::PARAM_STR)
            && $statement->bindValue(':date', date("Y-m-d H:i:s"), PDO::PARAM_STR)
            && $statement->bindValue(':ip', $this->ip, PDO::PARAM_STR);
         if (!$ok)
         {
            echo "<br><br>bindValue failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($db->errorInfo(), true) . "</p>";
         }
      }
      if ($ok)
      {
         $ok = $statement->execute();
         if (!$ok)
        /* geben Warnung wenn nicht nach datenbank geschickt hat, wenn code all vertig ,muss '#' geben */
         {
            echo "<br><br>execute failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($db->errorInfo(), true) . "</p>";
         }


      }
      echo "<br/><br/><span>Data Inserted successfully...!!</span>";
       $this->db = null;
       return $ok;


    }    
    function getMessages()
    {
         $db = $this ->getConnection();
         if (!$db) return false;
         {
            $sql = "SELECT name, email, message, datetime FROM mela ORDER BY datetime DESC";
            $statement = $db->query($sql);
            if (!$statement)
            {
              $this->reportPDOError("Cannot create query", $sql, $db);
               return false;
            }
           $result = $statement->fetchAll(PDO::FETCH_ASSOC);

          if ($result === FALSE)
             $this->reportPDOError("fetchAll(ASSOC) failed", $sql, $statement);

          return $result;
       }
     }

      private function getConnection()
      {
          // Establish connection with MYSQL Server
          try
          {
             return new PDO("mysql:host=localhost;dbname=meine", "root", "pass");
          }
          catch (PDOException $pe)
          {
             echo "<br>Cannot connect to database: " . $pe->getMessage();
             return false;
          }
      }

      private function reportPDOError($message, $sql, $pdo)
      {
         $info = $pdo->errorInfo();

         echo "<div style='color:red'><b>Error in SQL Access: $message</b>";
         echo "<br>SQL-Statement: $sql";
         echo "<br>PDO SQLSTATE: $info[0]";
         echo "<br>MySQL error code: $info[1]";
         echo "<br>MySQL error message: $info[2]</div>";
      }
     
}
            
$Newobject = new ClassProveContakt1();
$Newobject -> ShowForm();
$Newobject ->  PostOkT();



    

?>

Now I to search with a New File my Comment to lose , with these File,

<?php

header('Content-Type: text/html; Charset=utf-8');
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>

<?php

require "classprove.php";




class ClassProveContakt2 
{


      private $dbHost = 'localhost'; # Host der Datenbank
	  private $dbName = 'meine';      # Name der Datenbank
	  private $dbUser = 'root';      # Name phpmyadmin
	  private $dbPass = 'pass';      # Passwort

      
      private $Name;
      private $Email;
      private $Message;
      private $PostOK;
      private $datetime;
      private $items;
      private $ip; 


     function ShowForms() 
    {
?>
      <form  method="POST">
        <br>
        <label for="name"><b>Name * </b></label>
        <input type="text" id="name" name="Name" value="">
        <label for="email"><b>E-mail * </b></label>
        <input type="email" id="email" name="Email" value="">
        <br><br>
        <label><b> Message * </b><br>
           <textarea cols="45" rows="6" id="text" name="Message"></textarea>      
        </label>
        <br><br>
        <input  type="submit" name="delete" value="delete" id="comment"/>
        <br> 
      </form>
<?php
    }

     



     function CommentToDatabase()
     {
        // Establish connection with MYSQL Server
       try
       {
         $db = new PDO("mysql:host=localhost;dbname=meine", "root", "pass");
       }
       catch (PDOException $pe)
       {
         echo "<br>Cannot connect to database: " . $pe->getMessage();
         return false;
       }
     }
     if(isset($_POST["id"])) {
        try {
               $connection = new PDO($id, $name, $email, $message, $datetime, $ip);

               $id = $_POST["id"];

               $sql = "DELETE FROM mela WHERE id = :id";

               $statement = $connection->prepare($sql);
               $statement->bindValue(':id', $id);
               $statement->execute();

               $success = "User successfully deleted";
        } catch(PDOException $error) {
          echo $sql . "<br>" . $error->getMessage();
        }
     }
     function tabelle() 
     {
        

       if ($statement) 
       {  
 
        echo "<table border=1>";
    
           echo "<tr>";
              echo "<th>ID</th>";
              echo "<th>Name</th>";
              echo "<th>Email</th>";
              echo "<th>Message</th>";
              echo "<th>Datetime</th>";
              echo "<th>IP</th>";
              echo "<th>Delete</th>";
            echo "</tr>";
   
            foreach ($statement as $row): 
       
              echo "<form action=classprove.php method=post>"
                 . "<tr>"
                   . "<td>" . htmlspecialchars($row["id"]) . "</td>"
                   . "<td>" . htmlspecialchars($row["name"]) . "</td>"
                   . "<td>" . htmlspecialchars($row["email"]) . "</td>"
                   . "<td>" . htmlspecialchars($row["datetime"]) . "</td>"
                   . "<td>" . htmlspecialchars($row["ip"]) . "</td>"
                   . "</tr>";
              
                 endforeach;
    
     
         echo "</table>"; 
      }
}

$Newobjects = new ClassProveContakt2();
$Newobjects -> ShowForms();
$Newobjects -> tabelle();


?>

But nothing to Display … ,
With sudo tail -n0 -f /var/log/apache2/error.log /var/log/mysql/error.log

to come

Parse error: syntax error, unexpected ‘<’, expecting end of file in /var/www/html/kommenter_verwalter.php on line 50

On Line 50 ,have my function ShowForm() and on the Line 50 , <br><br>

I to want a Table as these,

Can Please anyone help me for this Problen , Thanks !

Now i have to change a litle my code,

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);










class ClassProveContakt2 
{


        private $dbHost = 'localhost'; # Host der Datenbank
	    private $dbName = 'meine';      # Name der Datenbank
	    private $dbUser = 'root';      # Name phpmyadmin
	    private $dbPass = 'pass';      # Passwort

      
       private $Name;
       private $Email;
       private $Message;
       private $PostOK;
       private $datetime;
       private $items;
       private $ip; 


    function ShowForm() 
    {

      <form method="POST" action="classprove.php">
        <label for="name"><b>Name * </b></label>
        <input type="text" id="name" name="Name" value="">
        <label for="email"><b>E-mail * </b></label>
        <input type="email" id="email" name="Email" value="">
        <br><br>
        <label><b> Message * </b><br>
           <textarea cols="45" rows="6" id="text" name="Message"></textarea>      
        </label>
        <br><br>
        <input  type="submit" name="post" value="POST COMMENT" id="comment">
      </form>

    }

    function CommentToDatabase()
    {
        // Establish connection with MYSQL Server
       try
       {
         $db = new PDO("mysql:host=localhost;dbname=meine", "root", "pass");
       }
       catch (PDOException $pe)
       {
         echo "<br>Cannot connect to database: " . $pe->getMessage();
         return false;
       }
     }
     if(isset($_POST["delete"])) {
        try {
               require classprove.php;
                
               $connection = new PDO($id, $name, $email, $message, $datetime, $ip);

               $id = $_POST["id"];

               $sql = "DELETE FROM mela WHERE id = :id";

               $statement = $connection->prepare($sql);
               $statement->bindValue(':id', $id);
               $statement->execute();

               $success = "User successfully deleted";
          }catch(PDOException $error) {
                 echo $sql . "<br>" . $error->getMessage();
          }
         

     }
     function tabelle() 
     {
        

       if ($sb) 
       {  
 
          echo "<table id='user' class='table table-bordered'>
             <tr>
              <th>id</th>
              <th>name</th>
              <th>email</th>
              <th>message</th>
              <th>datetime</th>
              <th>ip</th>
             </tr>";
    
           
   
            foreach ($sb as $row): 
       
              echo "<form action=classprove.php method=post>"
                 . "<tr>"
                   . "<td>" $row["id"]"</td>"
                   . "<td>" $row["name"]"</td>"
                   . "<td>" $row["email"]"</td>"
                   . "<td>" $row["datetime"]"</td>"
                   . "<td>" $row["ip"]"</td>"
                   . "</tr>"
                   . "</form>";  
              
                      endforeach;
    
     
         echo "</table>"; 
       }
      }
}

$Newobjects = new ClassProveContakt2();
$Newobjects -> ShowForms();
$Newobjects -> tabelle();


?>

With sudo tail -n0 -f /var/log/apache2/error.log /var/log/mysql/error.log

to come these error,

Parse error: syntax error, unexpected ‘private’ (T_PRIVATE), expecting end of file in /var/www/html/kommenter_verwalter.php on line 10