Jump to content

[SOLVED] Saving Checkbox Values


Kathy_OC

Recommended Posts

I have a multi-screen form where the user creates a record when they click submit on the first screen and then the record is updated as they complete the following screens.  It works great for the first two screens, but on the third screen I have 3 checkboxes and I haven't been able to update the checkbox values in my database (MySQL).  Each checkbox is a tinyint field in the database and the checkbox value displays correctly when I echo it to the screen.  Also, I'm using adodb in case that matters.

 

What do I need to do to get this to work?

 

Thanks,

Kathy

 

Here's a code snippet:

 

	if ($_POST['chkCIP']) {
		// box was checked
		$CIP = 1;
	} else {
		// box was not checked
		$CIP = 0;
	}
	echo "CIP = " . $CIP . "<br>";

	$result = $db->Execute("UPDATE request SET CIP=? WHERE RequestID=?",array($CIP, $RequestID));

Link to comment
Share on other sites

the checkbox should return a value (example checkbox)

<input type="checkbox" name="test" value="true">

Now, with that said, you check against the checkbox value, not the existence of the checkbox

<?php
if ($_POST['test'] == "true"){
//do this
}
else{
//do that
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.