Copy link to clipboard
Copied
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
...Copy link to clipboard
Copied
Please don't post duplicate threads with what is essentially the same question. I have deleted your original thread.
I think I know what is wrong with your code, but I need to check how GetSQLValueString() handles user-defined values first.
Copy link to clipboard
Copied
sorry for the duplicate post, i made one late last night and wasnt sure i covered what i was trying to get across
do you need anything from me?
Copy link to clipboard
Copied
No, I think that my answer above should cover everything.
If you don't get an answer to a post, and think that more information might be needed, just add to the original thread. It makes it much easier for everyone if all related issues are kept in one thread.
Copy link to clipboard
Copied
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".
Copy link to clipboard
Copied
I understand, so basically what ever value you are using to store in the DB is the value that needs to be checked so we are using y and N if we were storing truw and flase we would check these values?
thats was a great help thank you
Copy link to clipboard
Copied
Yes, it's the value that's stored in the database that matters.