php-guestbook/index.php

52 lines
1.0 KiB
PHP
Raw Normal View History

2021-12-10 20:22:06 +00:00
<!DOCTYPE html>
2021-12-10 23:53:23 +00:00
<?php
2021-12-22 21:41:48 +00:00
2021-12-10 23:53:23 +00:00
require_once('persistence.php');
$db = createDB();
2021-12-22 21:41:48 +00:00
2021-12-10 23:53:23 +00:00
?>
2021-12-22 21:41:48 +00:00
2021-12-21 19:28:43 +00:00
<html lang="en">
2021-12-22 21:41:48 +00:00
2021-12-10 20:22:06 +00:00
<head>
2021-12-10 22:54:03 +00:00
<meta charset="utf-8"/>
<title>Guestbook</title>
2021-12-10 20:22:06 +00:00
</head>
2021-12-22 21:41:48 +00:00
2021-12-10 20:22:06 +00:00
<body>
2021-12-21 19:28:43 +00:00
2021-12-22 21:41:48 +00:00
<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>
2021-12-10 23:53:23 +00:00
<?php
2021-12-22 21:41:48 +00:00
//var_dump(storeUser($db, 'Dendy', 'Penisgros'));
//storeMessage($db, 'Content', 1);
//var_dump(userFromMessage($db, 2));
2021-12-21 19:28:43 +00:00
$test = getMessages($db);
foreach($test as $msg) {
2021-12-22 21:41:48 +00:00
//var_dump($msg);
2021-12-21 19:28:43 +00:00
echo('<div class="message">');
2021-12-22 21:41:48 +00:00
$usr = userFromMessage($db, $msg['id_msg']);
$username = $usr ? $usr['username'] : 'Anonymous';
echo($username);
echo('<br>');
echo('---');
echo('<br>');
echo($msg['content']);
echo('<br>');
2021-12-21 19:28:43 +00:00
echo('</div>');
echo('<br/>');
}
2021-12-22 21:41:48 +00:00
2021-12-10 23:53:23 +00:00
?>
2021-12-22 21:41:48 +00:00
2021-12-10 20:22:06 +00:00
</body>
</html>