Checkbox Help with setting cookies


I currently have a form set up that allows some options to be selected from checkbox’s


Please select the tools you wish to pull-up automatically when launching an account.


	$result = mysql_query("SELECT * from links where status = 'enabled'");
		$num_rows = mysql_num_rows($result);

			while ($row = mysql_fetch_assoc($result)) {

				$cookie = $row['cookie'];

if ($_COOKIE['$cookie'] == "1") { $is_checked = "checked"; } else { $is_checked = ""; }

echo "<label for=\"{$row['label']}\"><input type=\"checkbox\" id=\"{$row['label']}\" value=\"1\" name=\"{$row['label']}\" $is_checked>{$row['label']}</label>";
echo "<br />";



I need to create a Loop that checks the results of the check box’s and if they are selected, they need to set the cookie for that.

The name of the cookie comes from the database and the value of it will be 1 for checked, 0 if not.

    setcookie($cookie, 'value', time() + (20 * 365 * 24 * 60 * 60)); 

So in short, for each checkbox that is selected, it needs to a cookie with the value of 1 and the name of the cookie will come from the database as $row[‘cookie’];

Unless there is an easier way to do this?

Sponsor our Newsletter | Privacy Policy | Terms of Service