Übung 7b2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>PHP-Kurs - Chatroom</title>
</head>
<body>
<?php
include("sauber.inc");
$nick = sauber($_REQUEST['nick']);
if($nick) {
echo "Hallo $nick, gib was ein:";
} else {
die("Ohne Nickname kein Chat!");
}
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input type="text" size="100" maxlength="100" name="chat"><br>
<input type="hidden" name="nick" value="<?php echo $nick; ?>">
<input type="submit" name="senden" value="senden">
</form>
<?php
if (isset($_POST['senden'])) {
$tmp = preg_replace('/#/', '', $_POST['chat']);
$tmp = sauber($tmp);
if($tmp) {
$ausgabe = $nick . '#' . $tmp . "\n";
$fh = fopen("/home/www/tuhhtest/intranet/chat.inc", "a");
fwrite($fh, $ausgabe);
fclose($fh);
} else {
echo "Nichts sinnvolles eingegeben, nochmal";
}
}
?>
<iframe src="ausgabe.php" width="95%" height="320" name="ausgabe">
</body>
</html>