isset not working on checkboxes
Posted: Wed Sep 13, 2006 9:04 am
Hi all,
I have an update users form, the simple problem I am having is setting the checkboxes as variables and then getting them into my query. I really cannot see from my code why this should not be already happening:
In this part I have retrieved the results from the database, now I want the users update to be sent back:
By echoing the query all the values for the checkboxes are null.
Any help would be much appreciated.
Thanks,
G
I have an update users form, the simple problem I am having is setting the checkboxes as variables and then getting them into my query. I really cannot see from my code why this should not be already happening:
Code: Select all
$id = $_SESSION['username'];
$query = "select * from suppliers where username='$id'";
//now we pass the query to the database
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error());
//get the first (and only) row from the result
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$first_name=$row['first_name'];
$last_name=$row['last_name'];
$address_line1=$row['address_line1'];
$address_line2=$row['address_line2'];
$test=$row['test'];Code: Select all
if(isset($_POST["submit"])){
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$address_line1=$_POST['address_line1'];
$address_line2=$_POST['address_line2'];
if (isset($_POST['test']) != "true"){
$test = "null";
}
$query = "UPDATE suppliers SET `first_name`='$first_name',
`last_name`='$last_name',
`password`='$password',
`address_line1`='$address_line1',
`address_line2`='$address_line2',
`test`='$test',
WHERE `username` = '". mysql_real_escape_string($_SESSION['username']). "'
LIMIT 1";
$result = mysql_query($query, $link) or die('Update failed: ' . mysql_error());
echo $query;
//print_r($query);
mysql_info($link) ;
if(mysql_affected_rows($link) == 0)
{
//$link next to affected rows and mysql query
echo '';
}
else
{
echo 'Your profile has been updated successfully, please click <a href=suppliers.php>here</a> for other options.';
}
?>By echoing the query all the values for the checkboxes are null.
Any help would be much appreciated.
Thanks,
G