Couple of things:
if (empty($_POST['insclass'])) {
$id = ($_POST['insclass']);
If you just established that $_POST['insclass'] is empty (possibly not even set), why would you attempt to use it as a value for a variable?
Also, if $_POST['insclass'] is defined, $id won't be.
You also have the if($id == 2) if() statement inside of the if($id == 1) statement, which obviously makes no sense at all.
I think you need to remove a lot of the extra spacing (one tab is plenty for indenting!) and follow your if() statements. Remove the HTML (which, in my opinion, shouldn't even be mixed with the PHP code) so it's easier to follow.
I would also recommend a decent editor; I, for example, use Notepad2 which allows me to click on an opening { or [ and the editor will show me where the matching } or ] is (if there is one - if not, it'll use a different color so that I know something doesn't match up).
Also, you have some redundant if() statements. For example, this:
$result = @mysql_query($query);
if (mysql_affected_rows() > 0)
{
if ($row = mysql_fetch_array($result))
{
could be reduced to this:
$result = @mysql_query($query);
if ($result && $row = mysql_fetch_array($result)) {
EDIT: Small MySQL optimization tip; since you're only expecting 1 row to be returned at most, you could add a 'LIMIT 1' clause onto the end of your queries.