hallo , ich habe das probleme die Tabelle wird nicht gebaut , auch bekomme keine Name , Email und Message auf meine datei ClassProveContakt2.php , der screenshot was auf dieser datei bekomme..
Der Code von ClassProveContakt2.php ;
<?php
require_once 'ClassProveContakt3.php';
error_reporting(E_ALL);
$mella = new ClassProveContakt3();
$mella -> ShowData();
Die Datei ClassProveContakt3.php wo meine ganze Code habe ;
<?php
header('Content-Type: text/html; Charset=utf-8');
mb_internal_encoding('UTF-8');
date_default_timezone_set('Europe/Berlin');
error_reporting(E_ALL);
class ClassProveContakt3
{
private $Name;
private $Email;
private $Message;
private $PostOK = false;
private $DateTime = false;
private $items = false;
function __construct()
{
$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()
{
echo ('<form method="POST">');
echo('<label for="name">Name </label>');
echo('<input type="text" name="Name" value="'.$this->Name.'">');
echo('<label for="email"> E-mail </label>');
echo('<input type="email" value="'.$this->Email.'" name="Email" ');
echo('<tr>');
echo('<td>');
echo('<br><br>');
echo('<label> Message: <br><textarea cols="45" rows="6" name="Message">'.$this->Message.'</textarea></label>');
echo('<br><br>');
echo('<input type="submit" name="post" value="POST COMMENT" id="comment">');
echo('</td>');
echo('</tr>');
echo('</form>');
}
function PostOkT()
{
if ($this -> PostOK)
{
return;
}
if (empty($this->Name) || empty($this->Email) || empty($this->Message))
{
echo "<br>" . "<b>" . "<h3>*** Please enter all required fields ***</h3>" . "</b>";
}
else
{
$file = "test.txt";
$name = filter_input( INPUT_POST, 'Name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'Email', FILTER_SANITIZE_STRING);
$message = filter_input(INPUT_POST, 'Message', FILTER_SANITIZE_STRING);
$datetime = date('m/d/Y h:i:s a', time());
$data = array("name" => $name, "email" => $email, "message" => $message, "datetime" => $datetime);
$data = serialize($data);
file_put_contents($file, $data . "\n", FILE_APPEND|LOCK_EX);
$messages = file($file);
foreach ($messages as $value) {
$data = unserialize($value);
echo "<br>"
. "<b>From: </b>" . htmlspecialchars( $data["name"])
. "<b> at: </b>" . htmlspecialchars( $data["datetime"])
. "<br><br>" . htmlspecialchars( $data["email"])
. "<br><br>" . htmlspecialchars( $data["message"])
. "<br><hr>";
}
}
}
function ShowData() {
$ShowItems = $this -> items;
array_unshift( $ShowItems, 'DateTime' );
echo "<table><tr>";
foreach ( $ShowItems as $ColName ) {
echo"<th>" . htmlspecialchars( $ColName ) . "</th>";
echo "</tr><tr>";
}
foreach ( $ShowItems as $ColName ) {
echo"<td>" . htmlspecialchars( $this -> $ColName ) . "</td>";
}
echo "</tr></table>";
}
}
?>
Auf meine Webformular Seite bekomme alles in Ordnung , wie der Screenhot zeigt...