I have a form built in Adobe Dreamweaver. It works, but when the checkboxes are checked the last checkbox value will submit to the database.
Are there any options in Dreamweaver to make the form make use of all of the checkboxes?
<?php require_once('Connections/MySQL_CSFTDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO articles (articletitle, articledescription) VALUES (%s, %s)",
GetSQLValueString($_POST['articletitle'], "text"),
GetSQLValueString($_POST['articledescription'], "text"));
mysql_select_db($database_MySQL_CSFTDB, $MySQL_CSFTDB);
$Result1 = mysql_query($insertSQL, $MySQL_CSFTDB) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
</style>
<![endif]-->
</head>
<body>
<div class="container">
<div class="header"><!-- end .header --></div>
<div class="sidebar1">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="#">Search</a></li>
<li><a href="addnew.php">Add New Article</a></li>
<li><a href="addnew.php">Article Admin.</a></li>
<li><a href="#">Tag Admin.</a></li>
</ul>
<p><!-- end .sidebar1 --></p>
</div>
<div class="content">
<h1>Article Database</h1>
<p>- Add a new article.</p>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<table width="100%" border="0" cellpadding="6">
<tr>
<td width="29%" align="right"><label for="articletitle">Article Title:</label> </td>
<td width="71%" align="left"><input name="articletitle" type="text" id="articletitle" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articleorganization">Article or Organization:</label></td>
<td align="left"><input name="articleorganization" type="text" id="articleorganization" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articledate">Access Date:</label></td>
<td align="left"><input name="articledate" type="text" id="articledate" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articledescription">Article Description:</label></td>
<td align="left"><input name="articledescription" type="text" id="articledescription" size="50" /></td>
</tr>
<tr>
<td colspan="2" align="center" valign="bottom"><p>Article Tags</p></td>
</tr>
<tr>
<td align="right"> </td>
<br />
<label>
<input type="checkbox" name="CheckboxGroup1" value="option 1" id="CheckboxGroup1_0" />
Checkbox 1</label>
<br />
<label>
<input type="checkbox" name="CheckboxGroup1" value="option 2" id="CheckboxGroup1_1" />
Checkbox 2</label>
<td align="left"><p>
<br />
<br />
</p></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><p><br />
</p></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<!-- end .content --></div>
<div class="footer">
</div>
<!-- end .container --></div>
</body>
</html>
Becomes
You can then read the values like this:
This makes sure the $selected variable is consistently an array. To find out whether a value was checked: