<?php

    
// Include the file that holds the database configuration
    
require('./config.php');

    
// Establish Database Connection
    
$db mysql_connect($host,$user,$pass); // Connect to the database server
    
mysql_select_db($database$db);     // Select the database we'll be using
    
    // echo the navigation
    
echo '<a href="index.php">home</a> | <a href="add.php"><strong>add data</strong></a> | <a href="retr.php">retreive data</a> | <a href="modify.php">modify data</a> | <a href="del.php">delete data</a>';
    
    
// Data is being submitted
    
if ($_POST['submit_data']) { // submit_data is set so the form was submitted.. 
        
$data $_POST['data']; // Put the info from the data form field into a single variable for easy access.
        
mysql_query("INSERT INTO data_table (`id`,`data`) VALUES (NULL,'$data')"); // Insert the data into the database
        
echo '<br/><br/>Data has been added to the database<br/>'// echo a message of succesion
        
echo 'Click <a href="./retr.php">here</a> to view the data'// Put the link to the next page
    
}
    
    
// echo the default page
    
echo '
        <form method="POST" action="add.php">
            <h2>Enter Data to Submit</h2>
            Data: <input type="text" size="25" name="data"/> <input type="submit" name="submit_data" value="Submit"/>
        </form>
            '
;
    
?>