Hello
I have a basic checkbox on a form that is not updating
when the box is checked it is updating the PHP DB but when i go back into the form the check box is not showing the correct value
php is
GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'"),
form value
<input type="checkbox" name="BankFinCCJ" <?php if (!(strcmp(htmlentities($row_Recordset1['BankFinCCJ'], ENT_COMPAT, 'utf-8'),"true"))) {echo "checked=\"checked\"";} ?> />
what am i doing wrong? can anyone help?
Your form should look like this:
<input type="checkbox" name="BankFinCCJ" <?php if (!(strcmp($row_Recordset1['BankFinCCJ'],"Y"))) {echo "checked=\"checked\"";} ?> />
You have misunderstood the following line:
GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'")
The GetSQLValueString() function takes up to four arguments. The first one is the value, the second is the type. And if the type is "defined", it takes two more arguments: the defined value, and the not-defined value.
The first argument to the function is this:
isset($_POST['BankFinCCJ']) ? "true" : ""
What that means is that if $_POST['BankFinCCJ'] exists, the value passed to GetSQLValueString() is "true". If it doesn't exist, an empty string is passed to the function. The "true" value is used internally by GetSQLValueString(). The actual values are "Y" and "N". That's why you need to test for "Y", and not for "true".
North America
Europe, Middle East and Africa
Asia Pacific