<?php

$host = "localhost"; // Adresse des Datenbankservers, meistens localhost
$user = "root"; // Ihr MySQL Benutzername
$pass = ""; // Ihr MySQL Passwort
$db = "cms2"; // Name der Datenbank
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>MooEditable basic example</title>
		<link rel="stylesheet" type="text/css" href="css/MooEditable.css" media="screen">
		
		<script type="text/javascript" src="js/mootools-1.2.1-core.js"></script>
		<script type="text/javascript" src="js/mootools-1.2.1-more.js"></script>
		<script type="text/javascript" src="js/MooEditable.js"></script>
		

<script type="text/javascript">
		window.addEvent('domready', function() {
		$('text').mooEditable();
		
		
			$('theForm').addEvent('submit', function(e) {
			e.stop();
			//Empty the log and show the spinning indicator.
			var log = $('log_res');
			//Set the options of the form's Request handler. 
			//("this" refers to the $('myForm') element).
			this.set('send', {onComplete: function(response) { 
				log.set('html', response);
			}});
			//Send the form.
			$('theForm').send();
		});

			
		});
		
		
		</script>

	</head>
	<body>

		<h1>MooEditable basic example</h1>

		<form id="theForm" method="post" action="save.php">
			
			<textarea class="mooeditable" id="text" name="text"></textarea>
			<input id="submit" name="submit" type="submit">

		</form>

		<div id="log">
		<h3>Ajax Response</h3>
		<div id="log_res">
		<?php
		$link = mysql_connect($host, $user, $pass) or die ("Keine Verbindung zu der Datenbank möglich.");
		mysql_select_db($db, $link);
		$result = mysql_query("SELECT text FROM texte WHERE id = 1");
		$data = mysql_fetch_array($result);
		echo $data['text'];
		mysql_close($link);
		?>
		</div>
	</div>

	</body>
</html>
