php-guestbook/index.php

52 lines
1.0 KiB
PHP
Executable File

<!DOCTYPE html>
<?php
require_once('persistence.php');
$db = createDB();
?>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Guestbook</title>
</head>
<body>
<form action="form.php" method="POST">
<label>Name:</label>
<input type="text" name="name"/><br/>
<textarea name="message" cols=50 rows=10 style="overflow:auto;"></textarea><br/>
<input type="submit" value="Submit"/><br/>
</form>
<?php
//var_dump(storeUser($db, 'Dendy', 'Penisgros'));
//storeMessage($db, 'Content', 1);
//var_dump(userFromMessage($db, 2));
$test = getMessages($db);
foreach($test as $msg) {
//var_dump($msg);
echo('<div class="message">');
$usr = userFromMessage($db, $msg['id_msg']);
$username = $usr ? $usr['username'] : 'Anonymous';
echo($username);
echo('<br>');
echo('---');
echo('<br>');
echo($msg['content']);
echo('<br>');
echo('</div>');
echo('<br/>');
}
?>
</body>
</html>