php - I have two similar functions while one output changes and the other doesn't -


This code uses html, php, and laravel. At first, a 'vaccine' does not change in value. The second one changes the 'NTK' value, but eventually my output on the webpage allows me to check the check box for some reasons. In fact, there is hope that someone can help me because I do not know how this is possible. Especially when I uncheck the wrong check box in $ ntk

This is my form:

  & lt ;? Php $ tk = session :: is ('tk')? Session :: Mill ('vaccine'): 1; Var_dump ($ t); If ($ tk == 1) {$ tk = 'true'; } And {$ tk = 'false'; } $ Tk_name = 'tk:'; Var_dump ($ tk_name); Var_dump ($ t); $ Ntk = session :: is ('NTK')? Session :: Mill ('NTK'): 0; Var_dump ($ NTK); If ($ ntk == 1) {$ ntk = 'true'; } And {$ ntk = 'false'; } $ Ntk_name = 'ntk:'; Var_dump ($ ntk_name); Var_dump ($ NTK); ? & Gt; {{Form :: open (array ('url' = & gt; 'envulen'))}} < Table & gt; & Lt; TR & gt; & Lt; TD & gt; {{Form: submit ('toepassen')}} & lt; / Td> & Lt; TD & gt; {{Form :: checkbox ('vaccine', 1, $ vaccine)}} sedative (vaccine) & lt; Br> {{Form: Checkbox ('NTK', 1, $ NTK)}} Nit-Tejdrict (NTK) & lt; Td> & Lt; / TR & gt; & Lt; / Table & gt; {{Form :: close}}}   

Here is my control code:

  if (isset ($ _ POST ['tk'])) {$ Vaccines = $ _POST ['vaccine']; Session: put ('vaccine', $ vaccine); } And {$ tk = 1; Session: put ('vaccine', $ vaccine); } If (pret ($ _ POST ['NTK'])) {$ ntk = $ _POST ['NTK']; Session: put ('NTK', $ NTK); } And {$ ntk = 0; Session: put ('NTK', $ NTK); }    

You are using:

  if ($ tk == 1) {$ tk = 'true'; } And {$ tk = 'false'; }   

In this case, $ tk is always correct because true is string not Boolean value and when you use the Boolean value as $ tk , it comes out of true Because it is a true value, for example:

  $ tk = 'false'; Echo !! $ Vaccines; // 1 = true   

Anyway, this problem is, your $ tk does not contain the string Boolean and the right to assign Method is a boolean value :

  $ k = TRUE; Without the Qoutes   

but you do not need to assign TRUE or FALSE to $ tk It: Enter the code here ($ tk == 1) {$ tk = true; } And {$ tk = false; }

Since, 0 a falsi value FALSE and 1 So you can use directly $ tk :

  {{form :: checkbox ('tk', 1, $ tk)}}   

$ tk 1 or 0 ) > This will be either:

  {{form :: checkbox ('vaccine', 1, 1)}} checked {{form :: checkbox ('vaccine', 1, 0) ))}} // Unchecked   

Therefore, if $ tk contains 1 then the checkbox Will be checked The and if 0 so that will not Czech .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -