<?php
if ( $_SESSION['IsAdmin'] )
	{
		echo "<h1>Über uns</h1>\n";
		$sql2		= "SELECT * FROM Uns WHERE ID = '1';";
		$result2	= $db->query($sql2);
		$nt2		= $result2->fetch_assoc();

		if ( isset ( $_POST['formaction'] ) AND ( "Speichern" == $_POST['formaction'] ) )
			{
				$sqls2 = 'UPDATE Uns SET
					Titel		= "' . $_POST['Titel0'] . '||' . $_POST['Titel1'] . '||' . $_POST['Titel2'] .'",
					Text		= "' . $_POST['Text0'] . '||' . $_POST['Text1'] . '||' . $_POST['Text2'] .'"
				WHERE ID = "1";';
				$stmts2		= $db->prepare($sqls2);
				if ( !$stmts2 )
					{
						die ('Datensatz konnte nicht gespeichert werden: '.$db->error);
					}
				if ( !$stmts2->execute() )
					{
						die ('Datensatz konnte nicht gespeichert werden: '.$stmts2->error);
					}
				$sql2		= "SELECT * FROM Uns WHERE ID = '1';";
				$result2	= $db->query($sql2);
				$nt2		= $result2->fetch_assoc();
				echo "<p class=\"hinweis\">Die Daten wurden gespeichert!</h2>\n";
			}
			$texte = explode ( '||', $nt2['Text'] );
			if ( !isset ( $texte[0] ) )
				{
					$texte[0] = '';
				}
			if ( !isset ( $texte[1] ) )
				{
					$texte[1] = '';
				}
			if ( !isset ( $texte[2] ) )
				{
					$texte[2] = '';
				}
			$titel = explode ( '||', $nt2['Titel'] );
			if ( !isset ( $titel[0] ) )
				{
					$titel[0] = '';
				}
			if ( !isset ( $titel[1] ) )
				{
					$titel[1] = '';
				}
			if ( !isset ( $titel[2] ) )
				{
					$titel[2] = '';
				}
			
			echo "<form action=\"index.php?".$_SERVER['QUERY_STRING']."\" method=\"post\">\n";
			echo "	<input style=\"width:225px;\" type=\"text\" name=\"Titel0\" value=\"" . $titel[0] . "\">\n";
			echo "	<input style=\"width:225px;\" type=\"text\" name=\"Titel1\" value=\"" . $titel[1] . "\">\n";
			echo "	<input style=\"width:225px;\" type=\"text\" name=\"Titel2\" value=\"" . $titel[2] . "\">\n";
			echo "	<br />&nbsp;<br />\n";
			echo "	<textarea style=\"width:225px;\" name=\"Text0\" rows=\"30\">" . $texte[0] . "</textarea>\n";
			echo "	<textarea style=\"width:225px;\" name=\"Text1\" rows=\"30\">" . $texte[1] . "</textarea>\n";
			echo "	<textarea style=\"width:225px;\" name=\"Text2\" rows=\"30\">" . $texte[2] . "</textarea>\n";
			echo "	<br />\n";
			echo "	&nbsp;<br />\n";
			echo "	<input type=\"submit\" name=\"formaction\" value=\"Speichern\" />\n";
			echo "	<input type=\"reset\" value=\"Rücksetzen\" />\n";
			echo "	<br />\n";
			echo "</form>\n";
			
	}

?>