<?php $dbhost = 'localhost';$dbusername = 'root';$dbpassword = 'mydbpass';$dbname = 'test';$conn=mysql_connect($dbhost, $dbusername, $dbpassword);if(!$conn) : die('Could not connect: ' . mysql_error());endif;$db=mysql_select_db($dbname, $conn);if(!$db) : die ('Can\'t connect to database : ' . mysql_error());endif;?>
<?phpinclude('config.php');if(isset($_POST['Submit'])){mysql_query("CREATE TABLE `page` ( `id` int(11) NOT NULL auto_increment, `text` text collate utf8_unicode_ci, `date` datetime, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1")or die(mysql_error());echo " Installation successful! ";}else{?><form method="post" action="install.php"><br><center><input type="Submit" name="Submit" value="Install"><center></form><?php}?>
<title>Insert Page</title><center><h2>INSERT PAGE</h2></center><BR><?phpinclude('config.php');if(isset($_POST['submit'])){$text = $_POST['text'];mysql_query("INSERT INTO page (text,date)VALUES ('$text',NOW())")or die(mysql_error()); echo "<a href=\"index.php\">Index Page</a>";}else{?><form method="post" action="insert.php"><TABLE><TR><TD>Title: </TD><TD><input name="text" size="60" maxlength="255"></TD></TR><TR><TD><input type="submit" name="submit" value="submit"></TD></TR></TABLE></form><?php}?>
<title>Index Page</title><center><h2>INDEX</h2></center><BR><?phpinclude('config.php');echo " <a href=\"insert.php\"><font face=\"tahoma\">INSERT PHP</a><br>";$result = mysql_query("SELECT * FROM page") or die(mysql_error()); while($link=mysql_fetch_array($result)){echo " <a href=\"page.php?id=$link[id]\">$link[text]</a><br>";echo "Text: $link[text] - Added:$link[date]<br>";}?>
<?phpinclude('config.php');$gid = $_GET['id'];$result = mysql_query("SELECT id, text, date FROM page WHERE id='$gid' ")//OR $result = mysql_query("SELECT * FROM page WHERE id='$gid' ")or die(mysql_error()); while($myrow = mysql_fetch_assoc($result)) {echo "<title>$myrow[text]</title>";echo "<center><h2>Text: $myrow[text] - Added:$myrow[date]</center><BR>";}?>