Jump to content

Recommended Posts

Posted

I have received so much help from this site and the amazing people on it. I am humbled by the amount of knowledge everyone here has. I am hoping that you can help me with something that I am struggling to figure out. I have a check box that successfully writes to my db but I can only get it to work with 1 and 0. I would like checked = yes unchecked to = no but I cant figure it out. Here is the code I am currently using.

<strong>Active: *</strong> <input type="checkbox" name="Active" value="1" <?php if($Active == 1) echo 'checked="checked"'; ?>"/><br/>
						

and 

$Active = (int)$_POST['Active'];
Posted

I actually tried that example before I posted. I'm sure I'm doing something wrong and probably very simple. I learn best by doing things relevant to something I enjoy but I've only been at this web stuff a few weeks

Posted (edited)

I got it working without any errors on my xampp setup by changing 

$Active = (int)$_POST['Active'];

to

$Active = !empty($_POST['Active']) ? 'yes' : 'no';  

Edited by scampbell70

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...