hello guys.. i have a problem..can anyone tell me how to solve this:

`Notice: Undefined index: BMK81A in C:wampwww`

my full code:

if ( isset($_POST['BMK81A']) && isset($_POST['BMK81']) && isset($_POST['DL3']) && isset($_POST['DL2']) && isset($_POST['DL1']) && isset($_POST['S1']) && isset($_POST['S2']) && isset($_POST['S3']) && isset($_POST['S4']) && isset($_POST['S5']) && isset($_POST['S6']) && isset($_POST['S7']) && isset($_POST['D1']) && isset($_POST['A1']) && isset($_POST['RE1']) && isset($_POST['LU2']) && isset($_POST['NPT']) && isset($_POST['SRP']) && isset($_POST['KTDP']) && isset($_POST['KDP']) && isset($_POST['USPD']) )

            $IC2= $_SESSION['IC2'];


            $BMK81A = $_POST['BMK81A'];
            $BMK81 = $_POST['BMK81'];
            $DL3 = $_POST['DL3'];
            $DL2 = $_POST['DL2'];
            $DL1 = $_POST['DL1'];
            $S1 = $_POST['S1'];
            $S2 = $_POST['S2'];
            $S3 = $_POST['S3'];
            $S4 = $_POST['S4'];
            $S5 = $_POST['S5'];
            $S6 = $_POST['S6'];
            $S7 = $_POST['S7'];
            $D1 = $_POST['D1'];
            $A1 = $_POST['A1'];
            $RE1 = $_POST['RE1'];
            $LU2 = $_POST['LU2'];
            $NPT = $_POST['NPT'];
            $SRP = $_POST['SRP'];
            $KTDP = $_POST['KTDP'];
            $KDP = $_POST['KDP'];
            $USPD = $_POST['USPD'];

it is true from this code? plse help me..i need solution!! :'( sory for my bad english!
i'm doing a checkboxes.. if i select a checkboxex, then it will insert into database. then it should update data in the database if have any changes made..

        in database, i'm doing a default value..if selected it will be become 1, if not selected will become 0. so from this, i want to update in the database..how to make it?           

Add the brackets to extend the statement, otherwise the IF condition will apply only to $IC2= $_SESSION['IC2']; because it finds the ; character, so:

if ( isset($_POST['BMK81A']) && isset($_POST['BMK81']) && isset($_POST['DL3']) && isset($_POST['DL2']) && isset($_POST['DL1']) && isset($_POST['S1']) && isset($_POST['S2']) && isset($_POST['S3']) && isset($_POST['S4']) && isset($_POST['S5']) && isset($_POST['S6']) && isset($_POST['S7']) && isset($_POST['D1']) && isset($_POST['A1']) && isset($_POST['RE1']) && isset($_POST['LU2']) && isset($_POST['NPT']) && isset($_POST['SRP']) && isset($_POST['KTDP']) && isset($_POST['KDP']) && isset($_POST['USPD']) )
{
        $IC2= $_SESSION['IC2'];


        $BMK81A = $_POST['BMK81A'];
        $BMK81 = $_POST['BMK81'];
        $DL3 = $_POST['DL3'];
        $DL2 = $_POST['DL2'];
        $DL1 = $_POST['DL1'];
        $S1 = $_POST['S1'];
        $S2 = $_POST['S2'];
        $S3 = $_POST['S3'];
        $S4 = $_POST['S4'];
        $S5 = $_POST['S5'];
        $S6 = $_POST['S6'];
        $S7 = $_POST['S7'];
        $D1 = $_POST['D1'];
        $A1 = $_POST['A1'];
        $RE1 = $_POST['RE1'];
        $LU2 = $_POST['LU2'];
        $NPT = $_POST['NPT'];
        $SRP = $_POST['SRP'];
        $KTDP = $_POST['KTDP'];
        $KDP = $_POST['KDP'];
        $USPD = $_POST['USPD'];

        # other code here

}

i have try to put brackets..but still doesnt work! why?
it become like this:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DL2='', DL1='', S1='', S2='', S3='', S4='', S5='', S6='', S7='', D1='', A1='', R' at line 1

This error is related to the insert query, check the syntax before 'DL2='', , if in doubt post your query here.

STILL DOESN'T WORK!:'(

here my code:

$IC2= $_SESSION['IC2'];
        $BMK81A = $_POST['BMK81A'];
        $BMK81 = $_POST['BMK81'];
        $DL3 = $_POST['DL3'];
        $DL2 = $_POST['DL2'];
        $DL1 = $_POST['DL1'];
        $S1 = $_POST['S1'];
        $S2 = $_POST['S2'];
        $S3 = $_POST['S3'];
        $S4 = $_POST['S4'];
        $S5 = $_POST['S5'];
        $S6 = $_POST['S6'];
        $S7 = $_POST['S7'];
        $D1 = $_POST['D1'];
        $A1 = $_POST['A1'];
        $RE1 = $_POST['RE1'];
        $LU2 = $_POST['LU2'];
        $NPT = $_POST['NPT'];
        $SRP = $_POST['SRP'];
        $KTDP = $_POST['KTDP'];
        $KDP = $_POST['KDP'];
        $USPD = $_POST['USPD'];




$query = " UPDATE  doku SET BMK81A='$BMK81A', BMK81='$BMK81', DL3='$DL3' DL2='$DL2', DL1='$DL1', S1='$S1', S2='$S2', S3='$S3', S4='$S4', S5='$S5', S6='$S6', S7='$S7', D1='$D1', A1='$A1', RE1='$RE1', LU2='$LU2', NPT='$NPT', SRP='$SRP', KTDP='$KTDP', KDP='$KDP', USPD='$USPD' WHERE NO_KPT2='$IC2' ";

mysql_query($query) or die(mysql_error());

Missing comma DL3='$DL3' DL2='$DL2', should be DL3='$DL3', DL2='$DL2',

TQ SIR..BUT STILL DOESNT'T WORK YET! IT SHOW LIKE THIS:

1) Notice: Undefined index: BMK81A in C:\
2) Incorrect integer value: '' for column 'BMK81A' at row 1
3) Notice: Undefined index: BMK81 in C:
4) Notice: Undefined index: DL3 in C: and so on

why this happened? what should i do to solve this? :'(

here my form:

<table width="614" bgcolor="#FFFFCC"   border="1" align="center">
  <tr>
    <th scope="col">



    <form method="post" action="prosesmak_doku.php">
      <div align="left">
        <p align="left">
          <input type="checkbox" name="doku[]" value="BMK81A" >
          1. BMK81A<br>

          <input type="checkbox" name="doku[]" value="BMK81" >
          2. BMK81 <br>

          <input type="checkbox" name="doku[]" value="DL3" >
          3. JPN-DL-3 / JPN-DL-4  <br>       

          <input type="checkbox" name="doku[]" value="DL2" >
          4. JPN-DL-2 <br>

          <input type="checkbox" name="doku[]" value="DL1" >
          5. JPN-DL-1 <br>

          <input type="checkbox" name="doku[]" value="S1" >
          6. Salinan Sijil Kelahiran / Permit Masuk / Passport / Pengesahan Taraf / Perakuan Taraf / Sijil Anak Angkat / Borang W <br>

          <input type="checkbox" name="doku[]" value="S2" >
          7. Salinan Sijil Warganegara Ibu / Bapa / Penjaga <br>


           <input type="checkbox" name="doku[]" value="S3" >
          8. Salinan Sijil Kelahiran / Permit Masuk  Passport dan Kad Pengenalan Ibu / Bapa / Penjaga<br>


          <input type="checkbox" name="doku[]" value="S4" >
          9. Salinan Sijil Kelahiran / Permit Masuk / Passport dan Kad Pengenalan Adik Beradik<br>

          <input type="checkbox" name="doku[]" value="S5" >
          10. Salinan Sijil Kelahiran/ Permit Masuk / Passport dan Kad Pengenalan Suami / Isteri/ Anak-anak<br>

          <input type="checkbox" name="doku[]" value="S6" >
          11. Sijil Kematian Ibu / Bapa / Adik-beradik / Suami / Isteri<br>

          <input type="checkbox" name="doku[]" value="S7" >
          12. Sijil Perkahwinan / Sijil Penceraian / Akuan Sumpah<br>

          <input type="checkbox" name="doku[]" value="D1" >
          13. Dokumen-dokumen Sokongan<br>

          <input type="checkbox" name="doku[]" value="A1" >
          14. Akuan Penerimaan Permohonan<br>

          <input type="checkbox" name="doku[]" value="RE1" >
          15. Resit Rasmi Bayaran Berjumlah RM..................Bertarikh.................No Resit...................<br>

          <input type="checkbox" name="doku[]" value="LU2" >
          16. Semakan LU2<br>

          <input type="checkbox" name="doku[]" value="NPT" >
          17. Notis Panggilan Temuduga<br>


         <input type="checkbox" name="doku[]" value="SRP" >
          18. Salinan Rekod Pendua<br>


          <input type="checkbox" name="doku[]" value="KTDP" >
          19. Kenyataan Temuduga DLKP Penganjur / Saksi<br>

          <input type="checkbox" name="doku[]" value="KDP" >
          20. Kenyataan DLKP Pemohon<br>

          <input type="checkbox" name="doku[]" value="USPD" >
          21. Ulasan Dan Sokongan Permohonan DLKP<br>

        <input name="PADAM" type="reset" value="RESET" />

        <input name="SIMPAN" type="submit" value="SIMPAN" />
      </div>
    </form>

  </tr>
</table>
</body>
</html>

Your are asking $_POST for the wrong values.. var_dump($_POST) and you should get an array of doku.

var_dump will look like this.

array(2) { ["doku"]=> array(5) { [0]=> string(3) "LU2" [1]=> string(3) "NPT" [2]=> string(3) "SRP" [3]=> string(4) "KTDP" [4]=> string(3) "KDP" } ["SIMPAN"]=> string(6) "SIMPAN" } 

You could try this:

Change your checkbox names to match your values;

<input type="checkbox" name="BMK81A" value="BMK81A" >
<input type="checkbox" name="BMK81" value="BMK81" >

SIR... I've changed the name from name="doku[]" to name="BMK81A"....
it still not working..what should i do next?:'(..but it appear like this:

DL1S1 <-- this appear if i select the checkbox..but still have error like this:

Notice: Undefined index: BMK81A in C:\ 2) Incorrect integer value: '' for column 'BMK81A' at row 1 3) Notice: Undefined index: BMK81 in C: 4) Notice: Undefined index: DL3 in C: and so on

you have to do this for all checkbox's

This is what the structure would look like.. just change the variables.

<?php

    if( isset($_POST['submit'] ){
        $val1 = $_POST['value1'];
        $val2 = $_POST['value2'];

        $sql = "INSERT INTO table SET val1='$val1', val2='$val2'";

        $q = mysql_query($sql);
    }




<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>" >
<input type="checkbox" name="value1" value="value1" />
<input type="checkbox" name="value2" value="value2" />
<input type="submit" name="submit" value="submit" />
</form>

SIR.. if i'm doing like this:

if ( isset($_POST['BMK81A']) && isset($_POST['BMK81']) && isset($_POST['DL3']) && isset($_POST['DL2']) && isset($_POST['DL1']) && isset($_POST['S1']) && isset($_POST['S2']) && isset($_POST['S3']) && isset($_POST['S4']) && isset($_POST['S5']) && isset($_POST['S6']) && isset($_POST['S7']) && isset($_POST['D1']) && isset($_POST['A1']) && isset($_POST['RE1']) && isset($_POST['LU2']) && isset($_POST['NPT']) && isset($_POST['SRP']) && isset($_POST['KTDP']) && isset($_POST['KDP']) && isset($_POST['USPD']) )
    {

        $IC2= $_SESSION['IC2'];
       $BMK81A = $_POST['BMK81A'];
        $BMK81 = $_POST['BMK81'];
        $DL3 = $_POST['DL3'];
        $DL2 = $_POST['DL2'];
        $DL1 = $_POST['DL1'];
        $S1 = $_POST['S1'];
        $S2 = $_POST['S2'];
        $S3 = $_POST['S3'];
        $S4 = $_POST['S4'];
        $S5 = $_POST['S5'];
        $S6 = $_POST['S6'];
        $S7 = $_POST['S7'];
        $D1 = $_POST['D1'];
        $A1 = $_POST['A1'];
        $RE1 = $_POST['RE1'];
        $LU2 = $_POST['LU2'];
        $NPT = $_POST['NPT'];
        $SRP = $_POST['SRP'];
        $KTDP = $_POST['KTDP'];
        $KDP = $_POST['KDP'];
        $USPD = $_POST['USPD'];



        $query = " UPDATE  smile2.maklumat_dokumen SET  BMK81A='$BMK81A', BMK81='$BMK81', DL3='$DL3', DL2='$DL2', DL1='$DL1', S1='$S1', S2='$S2', S3='$S3', S4='$S4', S5='$S5', S6='$S6', S7='$S7', D1='$D1', A1='$A1', RE1='$RE1', LU2='$LU2', NPT='$NPT', SRP='$SRP', KTDP='$KTDP', KDP='$KDP', USPD='$USPD' WHERE NO_KPT2='$IC2' ";

mysql_query($query) or die(mysql_error());

    }

output: it become blank page.

if i'm doing like this:

    if ( isset($_POST['BMK81A']) && isset($_POST['BMK81']) && isset($_POST['DL3']) && isset($_POST['DL2']) && isset($_POST['DL1']) && isset($_POST['S1']) && isset($_POST['S2']) && isset($_POST['S3']) && isset($_POST['S4']) && isset($_POST['S5']) && isset($_POST['S6']) && isset($_POST['S7']) && isset($_POST['D1']) && isset($_POST['A1']) && isset($_POST['RE1']) && isset($_POST['LU2']) && isset($_POST['NPT']) && isset($_POST['SRP']) && isset($_POST['KTDP']) && isset($_POST['KDP']) && isset($_POST['USPD']) )
        {

            $IC2= $_SESSION['IC2'];
           $BMK81A = $_POST['BMK81A'];
            $BMK81 = $_POST['BMK81'];
            $DL3 = $_POST['DL3'];
            $DL2 = $_POST['DL2'];
            $DL1 = $_POST['DL1'];
            $S1 = $_POST['S1'];
            $S2 = $_POST['S2'];
            $S3 = $_POST['S3'];
            $S4 = $_POST['S4'];
            $S5 = $_POST['S5'];
            $S6 = $_POST['S6'];
            $S7 = $_POST['S7'];
            $D1 = $_POST['D1'];
            $A1 = $_POST['A1'];
            $RE1 = $_POST['RE1'];
            $LU2 = $_POST['LU2'];
            $NPT = $_POST['NPT'];
            $SRP = $_POST['SRP'];
            $KTDP = $_POST['KTDP'];
            $KDP = $_POST['KDP'];
            $USPD = $_POST['USPD'];

            }

            $query = " UPDATE  smile2.maklumat_dokumen SET  BMK81A='$BMK81A', BMK81='$BMK81', DL3='$DL3', DL2='$DL2', DL1='$DL1', S1='$S1', S2='$S2', S3='$S3', S4='$S4', S5='$S5', S6='$S6', S7='$S7', D1='$D1', A1='$A1', RE1='$RE1', LU2='$LU2', NPT='$NPT', SRP='$SRP', KTDP='$KTDP', KDP='$KDP', USPD='$USPD' WHERE NO_KPT2='$IC2' ";

    mysql_query($query) or die(mysql_error());

output: Notice: Undefined variable: S1, Notice: Undefined variable: S2 in C:\ and so on

~ Do I edit the code wrong? :'(

The first code block can work, the second no, because when the IF statement fails it will run the query anyway, generating an error.

Now, as suggested by Gabriel, you have to verify if the checkboxes are set, if you're still using the doku[] array, you can create a white list of expected values:

<?php

    if($_POST['doku'] && is_array($_POST['doku']))
    {
        # BMK81A
        if(in_array('BMK81A', $_POST['doku']))
            $BMK81A = 1;
        else
            $BMK81A = 0;

        # BMK81
        if(in_array('BMK81', $_POST['doku']))
            $BMK81 = 1;
        else
            $BMK81 = 0;

        # DL3 and so on ...



        # update query here

    }

And repeat the IF statment for each element of the doku array. It's important to set a default value for the missing checkboxes, otherwise the update query will run fine only when all checkboxes are checked.

SIR cereal.. I've changed to using the doku[]..and i'm doing the IF statement..but the data in database doesn't changed! why? it still 0 and not changed to 1 if i'm select any checkbox in form page. what should i do?:'(

When you set your checkbox too name="doku[]", you are creating an array with the name of doku. So when you catch the $_POST['doku'] value, you will have all the checkbox values within the doku array.

Like so:

doku => array(
    0 => BMK81A,
    1 => BMK81,
    2 => DL1,
    etc.. 
    etc.. 
    the list goes on through the whole array.
    );

Your query is asking for the wrong value because, you have all your values in the doku array

you need to do this:

$DL1 = $_POST['doku'][4];

echo $DL1 and you should get the value from the checkbox.

I can tell you now, you are going about this in a very hard way, and should change this up. Like I said in my other post. If you are using checkbox's you should have the name and the value be the same.

This should work for you

if( isset($_POST['submit']) ){

    $IC2= $_SESSION['IC2'];

    $BMK81A = $_POST['doku'][0];
    $BMK81 = $_POST['doku'][1];
    $DL1 = $_POST['doku'][2];
    $DL2 = $_POST['doku'][3];
    $DL3 = $_POST['doku'][4];
    $S1 = $_POST['doku'][5];
    $S2 = $_POST['doku'][6];
    $S3 = $_POST['doku'][7];
    $S4 = $_POST['doku'][8];
    $S5 = $_POST['doku'][9];
    $S6 = $_POST['doku'][10];
    $S7 = $_POST['doku'][11];
    $D1 = $_POST['doku'][12];
    $A1 = $_POST['doku'][13];
    $RE1 = $_POST['doku'][14];
    $LU2 = $_POST['doku'][15];
    $NPT = $_POST['doku'][16];
    $SRP = $_POST['doku'][17];
    $KTDP = $_POST['doku'][18];
    $KDP = $_POST['doku'][19];
    $USPD = $_POST['doku'][20];






     $query = " UPDATE smile2.maklumat_dokumen SET BMK81A='$BMK81A', BMK81='$BMK81', DL3='$DL3', DL2='$DL2', DL1='$DL1', S1='$S1', S2='$S2', S3='$S3', S4='$S4', S5='$S5', S6='$S6', S7='$S7', D1='$D1', A1='$A1', RE1='$RE1', LU2='$LU2', NPT='$NPT', SRP='$SRP', KTDP='$KTDP', KDP='$KDP', USPD='$USPD' WHERE NO_KPT2='$IC2' ";


    mysql_query($query) or die(mysql_error());

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.