Ok, if this isn't what you wanted let me know and I'll try to fix it.
mysql.php
This file is to set the host name, user name, password, and database name for your MySQL database (which you setup in your hosting somewhere).
PHP Code:
<?php
// Edit the content of these variables as needed
$host = 'localhost'; // This is the host, and is normally localhost
$user = 'root'; // This is the database username
$pass = 'root'; // This is the database password
$db = 'dbname'; // This is the database name itself
$connect = @mysql_connect ($host, $user, $pass) or die ('<b>ERROR:</b> Could not connect to database!');
$select = @mysql_select_db ($db) or die ('<b>ERROR:</b> Could not select database!');
?>
enter.php
This file will enter the information from the form to the database
PHP Code:
<?php
require_once ('mysql.php');
if (isset ($_POST['submit'])) {
// These next three variables get the information from the text fields
// below
$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
$field3 = $_POST['field3'];
if (!empty ($field1) && !empty ($field2) && !empty ($field3)) {
$sql = "INSERT INTO table_name (field_id, field1, field2, field3) VALUES (0, '".$field1."', '".$field2."', '".$field3."')";
if ($r = mysql_query ($sql)) {
echo 'Your info has been entered successfully!';
}
} else {
echo 'You didn\'t fill out all the required fields, please try again!';
}
} else {
echo '<form action="enter.php" method="post">
Field 1 <input type="text" name="field1" />
<br />
Field 2 <input type="text" name="field2" />
<br />
Field 3 <input type="text" name="field3" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>';
}
?>
view.php
This file will view the information in the database, ordered by newest to oldest
PHP Code:
<?php
require_once ('mysql.php');
$sql = "SELECT * FROM table_name ORDER BY field_id DESC";
if ($r = mysql_query ($sql)) {
$num = mysql_num_rows ($r);
if ($num > 0) {
echo '<table border="0" width="500px">
<tr>
<td align="center"><b>Field 1</b></td>
<td align="center"><b>Field 2</b></td>
<td align="center"><b>Field 3</b></td>
</tr>';
while ($row = mysql_fetch_array ($r)) {
echo '<tr>
<td align="center">'.$row['field1'].'</td>
<td align="center">'.$row['field2'].'</td>
<td align="center">'.$row['field3'].'</td>
</tr>';
}
echo '</table>';
} else {
print 'There is no information yet.';
}
}
?>
You will have to change "table_name" in both enter.php and in view.php to whatever you call your database table name.
I recommend taking a small, basic tutorial on MySQL so you are familiar with the terms and how everything works. It's not very complicated and can be learned quickly.
If this isn't what you wanted, I will try to change it so it is what you want. Let me know if you have any problems.