Hi all,
Its late here and i have been staring at this for some time now. I simply want to input the values from two checkboxes into mysql. I can get the checkboxes to check when I submit the form, but the update to the table is not working, I am not getting any errors, including mysql ones when I screw up the query, but i cannot see why this is not working! the database connection is made and works fine as I have run a select query above this code and printed the results, I am sure it is something simple:
if (isset($_POST['headlines']) != "true"){
$headlines = "no";
}
else{
$headlines = "true";
}
//////////FAMILY/////////////////////////////
if (isset($_POST['family']) != "true"){
$family = "no";
}
else{
$family = "true";
if (isset($_POST['submit'])){
$query = "UPDATE content_selection SET `headlines`='$headlines', `family`='$family' where userid='" . mysql_real_escape_string($userid) . "'";
$result = mysql_query($query) or die('Update failed: ' . mysql_error());
if (mysql_affected_rows() != 1) {
//$link next to affected rows and mysql query
echo "<p>Query = $query";
echo '<p>nothing</p>';
}
else
{
echo '<p>$query</p>';
echo '<p>result = $result</p>';
}
}
?>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<body>
<form name="UserInformationForm" method="POST" action="#">
<input name="headlines" type="checkbox" value="true" <?php if($_POST['headlines']=="true") echo "checked=checked"; ?> > Headlines
<input name="family" type="checkbox" value="true" <?php if($_POST['family']=="true") echo "checked=checked"; ?> > Family
<br/><br/>
<input name="Submit" type="submit" value="Submit">
</form>
</body>
</html>
Thanks for any help!
G