jetzt habe keine Datenbank , erste möchte meine Website vertig machen...ich habe eine Website als probe gemacht , ich möchte erste lernen mit ihre... ich habe auf ihn nur zwei PHP , sie sind diesen...
Erste:
<?php
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()
{
?>
<form method="POST">
<label for="name"><b>Name * </b></label>
<input type="text" id="name" name="Name" >
<label for="email"><b> E-mail * </b></label>
<input type="email" id="email" name="Email" >
<br><br>
<label><b> Message * </b><br>
<textarea cols="45" rows="6" name="Message"></textarea>
</label>
<br><br>
<input type="submit" name="post" value="POST COMMENT" id="comment">
</form>
<?php
}
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";
$datetime = date('m/d/Y h:i:s a', time());
$data = array("name" => $this->Name, "email" => $this->Email, "message" => $this->Message, "datetime" => $this -> DateTime);
$data = json_encode($data);
file_put_contents($file, $data . "\n", FILE_APPEND|LOCK_EX);
$messages = file($file);
foreach ($messages as $value) {
$data = json_decode($value, true);
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>";
}
}
}
}
$me = new ClassProveContakt3();
$me -> ShowForm();
$me -> PostOkT();
?>
Zweite:
<?php
class NavigationLinkList {
private $current_page;
private $arLinks;
public function __construct( $arNewLinks = false ) {
$this -> arLinks = [];
$this -> addLinks ( $arNewLinks );
$this -> current_page = $_SERVER['REQUEST_URI'];
}
public function addLinks ( $arNewLinks ) {
$flagErrors = false;
if ( isset( $arNewLinks['URL'] ) && isset( $arNewLinks['TEXT'] ) ) { #Auf diesen if ,baut der array ...
array_push( $this -> arLinks, $arNewLinks );
return true;
}
if ( is_array ( $arNewLinks ) ) {
foreach ( $arNewLinks as $NewLink ) {
if ( isset( $NewLink['URL'] ) && isset( $NewLink['TEXT'] ) ) {
array_push( $this -> arLinks, $NewLink );
}
}
} else {
$flagErrors = true;
}
return false == $flagErrors;
}
public function printNav() {
echo '
<form class="link_wechsel">
<ul>' . PHP_EOL;
foreach ( $this -> arLinks as $link ) {
if ( $this -> current_page == $link['URL'] ) {
$aria = ' aria-current="page"';
} else {
$aria = '';
}
echo ' <li><a' . $aria . ' href=' . $link['URL'] .'>' . $link['TEXT'] . '</a></li>' . PHP_EOL;
}
echo '
</ul>
</form>' . PHP_EOL;
}
}
$_SERVER['REQUEST_URI'];
$navListe = new NavigationLinkList();
$navListe -> addLinks( [ 'URL' => '/meine/windows.php', 'TEXT' => '1' ] );
$navListe -> addLinks( [ 'URL' => '/meine/windows_2.php', 'TEXT' => '2' ] );
$navListe -> printNav();
man kann sage , das ich diesen Code von euch bekomme habe ☺️ ,was ist deine Meinung ??