I think I am going to start a compilation of scripts that I have created and believe are useful . Here is the first one, it is an extremely simple guestbook using php and mysql.
Code:
Code:
Edit: Also this one isn't very safe, i forgot to strip entities i will fix that later.
Code:
//guestbook.php
<html>
<head>
<title>Simple Guestbook</title>
</head>
<body>
<h1>Simple Guestbook with Php</h1>
<p>This is a simple guestbook application written with php. Just fill out the form below and click submit.
And the php will take care of the rest.</p>
<br />
<?php
//User defined database information
$dbname = "";
$dbuser = "";
$dbpass = "";
$dbhost = "";
$link = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$link) {
die("Couldn't connect to MySQL");
}
mysql_select_db($dbname) or die("Couldn't open $database");
$result = mysql_query("SELECT * FROM entries");
while ($row = mysql_fetch_array($result)) {
echo "<strong>" . $row['name'] . "</strong>" . "      " . "<em>". $row['email'] . "</em>";
echo "<br />";
echo $row['comments'];
echo "<br />";
}
mysql_close($link);
?>
<form action="gbsubmit.php" method="post">
Name:<input type="text" name="name" />
<br />
E-mail:<input type="text" name="email" />
<br />
Comment:<input type="text" name="comment" />
<input type="submit" value="Send" />
</form>
</body>
</html>
Code:
//gbsubmit.php
<?php
//User defined database information
$dbname = "";
$dbuser = "";
$dbpass = "";
$dbhost = "";
$link = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$link) {
die("Couldn't connect to MySQL");
}
mysql_select_db($dbname) or die("Couldn't open $database");
$query = "INSERT INTO entries(name, email, comments) values('$_POST[name]','$_POST[email]','$_POST[comment]')";
mysql_query($query, $link) or die ("INSERT error: ".mysql_error());
mysql_close($link);
print "Thank you your entry has been submitted";
?>
Edit: Also this one isn't very safe, i forgot to strip entities i will fix that later.