I need some extra eyes to help me figure out what is wrong! I have one entry form and a second form that does the updating. I have a checkbox for 'Entered' that works great but the checkbox for 'Proof' does not work. If I manually enter the value in the database (through phpAdmin) the value will show on my form and I can uncheck it and it will then save as unchecked, but if there is no value in it to begin with and I check it, it will not save as checked. I copied and pasted the line for the 'Entered' checkbox and just changed the values to match the 'Proof' information. Here are my forms (they may be condensed - form one is very long and mostly repeats itself with different values for radio buttons):

Form1:

<?php
$con = mysql_connect("***","***","***");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("***", $con);
$search=$_POST['search'];
if($search==""){$search=$_REQUEST['id'];}

$d=date("Y-m-d H:i:s");
$sql="INSERT INTO IP (WO, Customer, Description, Status, Entered, Date, Proof)VALUES('$search','','','','','$d','')";

mysql_query($sql,$con);
$data = 'SELECT * FROM IP WHERE WO = "'.$search.'"'; 
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error()); 
  $data2 = mysql_fetch_array($query); 
 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
      <title></title> 
<link rel="stylesheet" href="ip.css" />
<script type="text/javascript" language="javascript">

    function redirect()
    {
        // you can also pass the complete URL of location
        // e.g.: http://www.google.com/ or
        // http://programming.top54u.com/Default.aspx
        
        location.replace("viewTable.php?id=WO");
    }

    </script>
</head> 
<body> 

<!-- form to display record from database --> 
<form name="form" method="POST" action="form2.php" target="hidden"> 
WO: <input type="text" name="WO" value="<?php echo $search?>" size=20"/><br /><br />
Customer: &nbsp;<input type="text" name="Customer" value="<?php echo $data2[Customer]?>" size="30"/><br /><br />
Description: &nbsp;<input type="text" name="Description" value="<?php echo $data2[Description]?>" size="30"/><br /><br />
<table width="40% border="0">
	<tr>
	<td width="50%" height="25">Status:</td>
	<td width="50%"height="25">Proof: <input name="Proof" id="Proof" type="checkbox" value="P" <?php if($data2['Proof'] == "P"){echo 'checked="checked"';}?> />
</td>
	</tr>
.
.
.
<table>
	<tr>
	<td width="50%" height="25"><input type="radio" name="Status" value="Bindery:Folder" <?php if($data2['Status'] == "Bindery:Folder"){echo 'checked="checked"';}?> />Folder</td>
	<td width="50%" height="25"><input type="radio" name="Status" value="Bindery:PaddingPrs" <?php if($data2['Status'] == "Bindery:PaddingPrs"){echo 'checked="checked"';}?> />Padding</td>
	</tr>
</table>
<table width="40% border="0">
	<tr>
	<td width="50%" height="25"><input type="radio" name="Status" value="Finished" <?php if($data2['Status'] == "Finished"){echo 'checked="checked"';}?> />Finished</td>
	<td align="center" width="50%" height="25"><input type="submit" value=" submit " />
	</tr>
	<tr>
	<td width="50%"height="25">Entered: <input name="Entered" id="Entered" type="checkbox" value="Y" <?php if($data2['Entered'] == "Y"){echo 'checked="checked"';}?> />
</td>
	<td align="center" width="50%" height="25"><input type="reset" value="  reset  " /></td>
	</tr>
</table>
</form>
<form><input type="button" value="Return to Tableview" onclick="redirect();" /></form>
</body> 
</html>

Form2:

<?php 

$con = mysql_connect("***","***","***");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("***", $con);
$t=time();
$Key=$_POST['WO'];
$WO=$_POST['WO']; 
$Customer=$_POST['Customer']; 
$Description=$_POST['Description']; 
$Status=$_POST['Status']; 
$Entered=$_POST['Entered'];
$Proof=$_Post['Proof'];
$d=date("Y-m-d H:i:s");

$data = "UPDATE IP SET WO='$WO', Customer='$Customer', Description='$Description', Status='$Status', Entered='$Entered', Date='$d', Proof='$Proof' WHERE WO=".'"'.$Key.'"'; 
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error()); 

?> 
<script type="text/javascript"><!--
function doRef(){
parent.main.location.href=window.main.location;
}
window.setInterval("doRef()",5000);
//--></script>

The line in red is the one I am having trouble with. The green line works fine. The rest of the form works great so you can ignore everything that doesn't pertain to this question.

did you do

var_dump($_POST);

to check what you got back?
if not checked a checkbox will give a $_POST var.

check if it exist

if(isset($_POST['Proof']))

furthere more before puting $_post in a db ALWAYS use
mysql_real_escape_string() to prevend hacking
this gives

if(isset($_POST['Proof'])) {
  $Proof = mysql_real_escape_string($_POST['Proof']) 
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.