<?
    $usr 
"--username--";
    
$pwd "--password--";
    
$db "linksdb";
    
$host "localhost";

    
# connect to database
    
$cid mysql_connect($host,$usr,$pwd);
    
mysql_select_db($db);
    if (
mysql_error()) { print "Database ERROR: " mysql_error(); }

?>
<html>
<head>
   <title>Insert Link</title>

</head>
<body bgcolor="#ffffff">

<h2> Add Link </h2>

<?
    
# this is processed when the form is submitted
    # back on to this page (POST METHOD)
    
if ($_SERVER['REQUEST_METHOD'] == "POST"
    {
        
# escape data and set variables
        
$category addslashes($_POST["category"]);
        
$sitename addslashes($_POST["sitename"]);
        
$siteurl addslashes($_POST["siteurl"]);
        
$description addslashes($_POST["description"]);

        
# setup SQL statement
        
$sql  " INSERT INTO links ";
        
$sql .= " (category, sitename, siteurl, description) VALUES ";
        
$sql .= " ('$category', '$sitename','$siteurl','$description') ";

        
#execute SQL statement
        
$result mysql_query($sql$cid);

        
# check for error
        
if (mysql_error()) { print "Database ERROR: " mysql_error(); }

        print 
"<p><b>new link added</b></p>\n";

    }

?>

    <form name="fa" action="insert_link.php" method="POST">     
    <table>                                                                                                        
    <tr><td><b>Category: </b> </td><td><input type="text" name="category" size=40></td></tr> 
    <tr><td><b>Site Name:</b> </td><td><input type="text" name="sitename" size=40></td></tr> 
    <tr><td><b>Site URL: </b> </td><td><input type="text" name="siteurl" value="http://" size=40></td></tr> 
    <tr><td valign=top><b>Description: </b> </td><td> <textarea name="description" rows=5 cols=40></textarea></td></tr>
    <tr><th colspan=2><p><input type="submit" value="Add Link"></p></th></tr> 
    </table>
    </form>                                      


</body>
</html>