1
0
mirror of https://github.com/php/web-php.git synced 2026-03-31 19:52:29 +02:00
Files
archived-web-php/oreilly99/s_sqlguest2.php3
1999-08-21 16:11:20 +00:00

26 lines
805 B
PHP

<?php require "header.inc"?>
<H1>SQL'izing the Guestbook Example</H1>
<?example('<html><head><title>My Guestbook</title></head>
<body>
<h1>Welcome to my Guestbook</h1>
<h2>Please write me a little note below</h2>
<form action="<? echo $PHP_SELF?>" method="POST">
<textarea cols=40 rows=5 name="note" wrap=virtual></textarea>
<input type="submit" value=" Send it ">
</form>
<?
mysql_connect("localhost");
if(isset($note)) {
$ts = date("Y-m-d H:i:s");
mysql_db_query("mydb","insert into comments values (0,\'$note\',\'$ts\')");
}
?>
<h2>The entries so far:</h2>
<? $result = mysql_db_query("mydb","select * from comments");
while($row=mysql_fetch_row($result)) {
echo $row[0] ." " . $row[1] . " " . $row[2] . "<br>\n";
} ?>
</body></html>')?>
<?php require "footer.inc"?>