isset(Checkboxname) returning true always

Hi,

I am using 2 text boxes and 2 check boxes in my page. I just want to retrieve the values of that and i want to store it in a Database.

This is the code:

(index.php)

  <div class="row">


	Username:


	<?php echo $form->textField($model,'uname'); ?>


	<?php echo $form->error($model,'uname'); ?>


</div><br>





<div class="row">


	


	Password:


	


	<?php echo $form->passwordField($model,'password'); ?>


	<?php echo $form->error($model,'password'); ?>


</div><br>





    <div  class="row">


	<?php echo $form->checkBox($model,'prov_flag'); ?>


	<?php echo $form->label($model,'prov_flag'); ?>


	<?php echo $form->error($model,'prov_flag'); ?>


	</div>





	<div  class="row">





	<?php echo $form->checkBox($model,'view_flag'); ?>


            <?php echo $form->label($model,'view_flag'); ?>


	<?php echo $form->error($model,'view_flag'); ?>


	</div>





<div class="row">		


	<input type="submit" name="submit" value="Submit">


</div>

And i am using session variables to store the value.I was able to retrieve the username and password successfully. But while checking whether check box is checked there is a problem.

It always returns true.

And the code is,

session_start();

	$_SESSION['cuname']=$this->uname;


	$_SESSION['cpasswd']=$this->password;


	$_SESSION['prov']=isset($this->prov_flag);

When i try to print the value,

echo $_SESSION[‘prov’];

It always printing 1. whether it is checked are not.

I don’t know whether i did any mistake.If so,please anyone correct me.

help me please…

yes because is allways setted isset(checkbox) mean :

is my checbox in url seted ?

yes it is and returns true,because is setted in form;

Solution for you you need to check if my checkbox is not empty and not equal to 0:




if(!empty('checkboxname') && (checboxname != 0)){

//now do the rest thing

}



Hi,

Thank u so much. Its working perfectly.