Hate to double post, but I worked on this mistake of the day script using mysql for quite a few minutes .
If you do decide to use mysql here is the query you will use:
Use this file called submit_mistake.php:
And this file called mistakes.php:
It is all tested and works fine, it displays it like this:
John - 5/21/2006
My mistake was I forgot to flush.
If you do decide to use mysql here is the query you will use:
Code:
CREATE TABLE mistakes (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
mistake VARCHAR(255) NOT NULL,
userip VARCHAR(255) NOT NULL,
datesub VARCHAR(255) NOT NULL
)
TYPE = myisam;
Use this file called submit_mistake.php:
Code:
<?php
// This file will insert the data entered in the fields to the database
// Connect to database
$host = "localhost";
$dbuser = "";
$dbpass = "";
$dbname = "";
mysql_connect($host, $dbuser, $dbpass) or die('Error connecting to the database');
mysql_select_db($dbname) or die('Could not select database');
// If the submit button is pushed
if(isset($_POST['submit'])) {
// POST Variables
$name = $_POST['name'];
$mistake = $_POST['mistake'];
$datesub = $_POST['datesub'];
$userip = $_POST['userip'];
// I added IP just so if anyone spams you, you can IP ban them
$query = mysql_query("INSERT INTO `mistakes` ( `name`, `mistake`, `datesub`, `userip` ) VALUES ('$name', '$mistake', '$datesub', '$userip');");
}
?>
<form action="" method="POST">
Name:<input type="text" name="name" value="$name" />
<br />
Your Mistake:<input type="text" name="mistake" value="$mistake" />
<input type="hidden" name="datesub" value="<?php echo date('m/d/Y'); ?>" />
<input type="hidden" name="userip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<Br />
<input type="submit" name="submit" value="Submit" />
And this file called mistakes.php:
Code:
<?php
// Connect to database
$host = "localhost";
$dbuser = "";
$dbpass = "";
$dbname = "";
mysql_connect($host, $dbuser, $dbpass) or die('Error connecting to the database');
mysql_select_db($dbname) or die('Could not select database');
// Mistakes file to retrieve the data from the database
$query = "SELECT * FROM mistakes ORDER BY id DESC";
$result = mysql_query($query) or die('Could not retrieve the information from the database');
if(mysql_num_rows($result) == 0){
echo("There are no mistakes yet!");
}
while($query=mysql_fetch_array($result)){
extract($query);
echo "
<b>$name</b> - $datesub
<BR>
  Â
$mistake
<BR><BR><BR>
";
}
?>
It is all tested and works fine, it displays it like this:
John - 5/21/2006
My mistake was I forgot to flush.