<form method='post' action=''>
Category name: <input type='text' name='cat_name' />
Category description: <textarea name='cat_desc' /></textarea>
<input type='submit' value='Add category' />
</form>
<?php
if($_SERVER['REQUEST_METHOD'] != 'POST')
{
$catname=mysql_real_escape_string('cat_name');
$catdesc=mysql_real_escape_string('cat_desc');
$sql = mysql_query("INSERT INTO fcategories (cat_name, cat_desc)
VALUES('','$catname','$catdesc')");
$result = mysql_query($sql);
if(!$result)
{
//something went wrong, display the error
echo 'Error' . mysql_error();
}
else
{
echo 'New category successfully added.';
}
}
?>
I have included connection to database. When I run the code, the there is an error in the bottom of my form.