Okay in the form I have this?
<?
include "common.php";
session_start();
if (isset($_SESSION['username']))
{
print "<center><A href='add.php'>Add a link</a>|<A href='delete.php'>|<A href='index.php'>Browse directory as Admin</a>|<A href='addcat.php'>Add a category</a>|<A href='deletecat.php'>Delete a category</a></center><br><br>";
print "<center><h3>Add a link</h3></center><br>";
print "<form action='addlink.php' method='POST'>";
print "<b>Name:</b> ";
print "<input type='text' name='name' length='15'><br><br>";
print "<b>Title:</b> ";
print "<input type='text' name='title' length='15'><br><br>";
print "<b>URL:</b> ";
print "<input type='text' name='url' length='15'><br><br>";
print "Category: ";
$result = mysql_query("SELECT CatName FROM cl_categories");
$row_array=mysql_fetch_row($result);
$string='<select name=Category><option value="">Select an Option</option>';
for ($i=0; $i < mysql_num_rows($result); $i++) {
if ($row_array[0] == "") {
$row_array=mysql_fetch_row($result);
} else {
$string .='<option value="'.$row_array[0].'">'.$row_array[0];
$row_array=mysql_fetch_row($result);
}
}
$string .='</SELECT>';
echo $string;
print"<br><br>";
print "Description: <br>";
print "<textarea rows='4' name='Description' cols='25'></textarea><br><br>";
print "<input type='submit' name='submit' value='submit'>";
}
else
{
echo "You are not logged in as an administrator";
}
?>
Now in addlink.php I have this:
<?
include "common.php";
session_start();
if (isset($_SESSION['username']))
{
print "<center><A href='add.php'>Add a link</a>|<A href='delete.php'>|<A href='index.php'>Browse directory as Admin</a>|<A href='addcat.php'>Add a category</a>|<A href='deletecat.php'>Delete a category</a></center><br><br>";
$SQL="Select from cl_categories where CatName='$Category'";
$r=mysql_query($SQL);
$CatID=$r[CatID];
$result="INSERT INTO cl_entries(name,CatID, EntryName, URL, Description) VALUES('$name', '$CatID', '$title', '$url', '$Description')";
mysql_query($result);
print "Link added successfully";
}
else
{
echo "You are not logged in as an administrator";
}
?>
It inserts just fine but the CatID is always zero. I said select where CatName=$Category and then insert that category's ID into CatID, but it ain't working.