Moin

I've just arrived today in your wonderful forum. Thank you that I may attend.

Today, I would love to share my small PHP Script, which I use for recording my dreams. I am a friend of plain, fast, basic things. This PHP Script has got an Input field, where you can input text, and when you save it your entry will be put into a weekly text file. That fits totally my actual needs of a dream journal. Maybe the one or another of you may find it helpful, too. Yes, you may edit, recode and share it like you want to. Have fun Life is too serious too not be amused of it.

Here comes the code; you may need to translate it. Do it yourself! You are much more better in your native language than I am. I guess this code is easy-peasy-lemon-squeezy to understand.

Gute Nacht (Good Night),

Sorieno

Code:
 
<?php

$name_der_datei = "traumtagebuch.php"; // der Name dieses Skripts

// Es folgen ein paar Datumsfunktionen
$timestamp = time(); //das ist genau JETZT
$datum = date("d.m.Y - H:i", $timestamp); // das ist das komplette Datum
$tag = date("w", $timestamp);
$tage = array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");
$kalenderwoche = 0;
$kalenderwoche = date('W', $timestamp);


// Überschrift für das Traumtagebuch
$ueberschrift = ' Traumtagebuch für '.$tage[$tag].', den '.date("d.m.Y", $timestamp).' um '.date("H:i", $timestamp).' Uhr';
$spacing1 = "═══════════════════════════════════════════════════════";
$spacing2 = "═══════════════════════════════════════════════════════";
$text = $spacing1."\r\n".
$ueberschrift."\r\n".
$spacing2."\r\n";
?>

<!-- Beginn der HTML Datei -->
<html>
<head>

<!-- Hier werden die Farben definiert. -->
<style type="text/css">

html {
	background-color: #222222; 
	color:white;
	font-size: 3vmin;
		font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

	}
		
textarea {
	width:98vw;
	height:60vh; 
	background-color:transparent; 
	color:white;
	border: 0px;
	font-size: 5vmin;
	margin-top:2vmin;
	}
	
.knopf {
	background-color:hsla(275, 100%, 37%, 0.44);
	color:white;
	border: 0px;
	padding:2vmin 4vmin 2vmin 4vmin;
	font-size: 5vmin;
	margin-top:2vmin;
}

.bildschirm {	
	width:98vw;
	height:60vh; 
	background-color:transparent; 
	color:white;
	border: 0px;
	font-size: 5vmin;
	margin-top:2vmin;
	}	
	
.okay {color:#00cc00;}	
.fehler {color:#cc0000;}
</style> 

</head>
<body>

<?php
echo '═════ '.$ueberschrift.' ═════';	
	// Beginnt erst, falls das Formular abgeschickt wurde.
	if (isset($_POST['traum'])) { 
		if ($_POST['traum'] == "") {echo '<div class="bildschirm"><span class="fehler">Traum wurde nicht gespeichert; bitte zuerst einen Traum aufschreiben.</span></div><a href="'.$name_der_datei.'"><input type="submit" id="Knopf" class="knopf" value="Okay."></a>'; die;}
		else {
		$text = $spacing1."\r\n".
		$ueberschrift."\r\n".
		$spacing2."\r\n".
		$_POST['traum']."\r\n".
		"\r\n";
		
		$dateiname = "KW_".$kalenderwoche.".txt"; // So wird d
		$datei = fopen($dateiname, "a");
		fwrite($datei, $text);
		fclose($datei);

		echo '<div class="bildschirm"><span class="okay">Der Traum wurde aufgeschrieben.</span><br></div><a href="'.$name_der_datei.'"><input type="submit" id="Knopf" class="knopf" value="Okay."></a>';
		
die; // Skriptausführung beenden
}
}

// Falls noch keine Eingabe getätigt wurde, zeige das Eingabeformular
else {
	?>

	<!-- das Eingabefeld -->
	<form name="myform" action="<?php $name_der_datei ?> " method="post">
	<textarea name='traum' placeholder="Schreibe hier deinen Traum auf." autofocus ></textarea>
	<input type="submit" id="Knopf" class="knopf" value="Traum aufschreiben.">
	</form>
	
</body>
</html>

<?php
} // Das Ende von der else-Abfrage
?>