I'm trying to update 2 separate tables in the same database dependent on form input. If a checkbox is checked, then it should update the second table - if it's not checked, then it shouldn't. No matter what I try, it won't update the second table. I think that it has to do with the if statement in code.php. Here's what I have:
code.php:
<?php
if (isset($HTTP_POST_VARS['add']))
{
// Set Mysql Variables
$host='xxxxx';
$user='xxxxx';
$pass='xxxxx';
$db='xxxxx';
$table='supp';
$table1='cat';
unset($id, $url, $name, $cat, $new);
// Set global variables to easier names
$url=$_POST['url'];
$name=$_POST['name'];
$cat=$_POST['cat'];
$new=$_POST['new'];
// Connect to Mysql, select the correct database, and run the query which adds the data gathered from the form into the
database
mysql_connect($host, $user, $pass) or die('Connection died!');
mysql_select_db($db) or die('Selection died!');
$add_all = "INSERT INTO $table (`url`, `name`, `cat`) values ('$url','$name','$cat')";
$add_all1 = "INSERT INTO $table1 (`cat`) values ('$cat')";
mysql_query($add_all) or die(mysql_error());
if ($new == "Yes"){
mysql_query($add_all1) or die(mysql_error());
include 'input2.inc.php';
}else{
include 'input2.inc.php';
}
else
{
include 'input2.inc.php';
}
?>
and input2.inc.php:
<HTML>
<HEAD>
<BODY>
<FORM METHOD="post" ACTION="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>">
<TABLE WIDTH=95% BORDER=2>
<TR>
<TD WIDTH=35% ALIGN=center>URL</TD>
<TD WIDTH=30% ALIGN=center>Name</TD>
<TD WIDTH=35% ALIGN=center>Category</TD>
</TR>
<TR>
<TD WIDTH=35% ALIGN=center><INPUT TYPE="text" NAME="url" SIZE="20"></TD>
<TD WIDTH=30% ALIGN=center><INPUT TYPE="text" NAME="name" SIZE="20"></TD>
<TD WIDTH=35% ALIGN=center><input type="text" name="cat" size="20"></TD>
</TR>
<TR>
<TD COLSPAN=5 ALIGN=center>New Category?<br /><INPUT TYPE="checkbox" NAME="new" VALUE="Yes">
</TD>
</TR>
<TR>
<TD COLSPAN=5 ALIGN=center><INPUT TYPE="submit" VALUE="Input" NAME="add">  <input type="reset"></TD>
</TR>
</TABLE>
</FORM>
</body>
</html>
I have a feeling that it's not passing the state of the checkbox to code.php. Does anyone know of a good way of doing this?