the following form collects data about the color preference of the visitors.
how can i insert a default value (For example, "No Color Chosen" is default value here) using explode function if the users submit the blank form when i don't want to prevent users from submitting the blank form.
i came up with the following syntax
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$color = "No Color Chosen ({$_POST['color_name']};)";
$colors = explode (" ", $color);
$insertSQL = sprintf("INSERT INTO colortable (color_id, color_name) VALUES (%s, %s)",
GetSQLValueString($_POST['color_id'], "int"),
GetSQLValueString(trim($colors[]), "text"),
mysql_select_db($database_x, $x;
$Result1 = mysql_query($insertSQL, $x) or die(mysql_error());
$insertGoTo = "choice.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td align="right" nowrap="nowrap">Enter Color Name:</td>
<td><input type="text" name="color_name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><input type="hidden" name="MM_insert" value="form1" /></td>
<td>
<input type="submit" value="Submit Color Name" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
how should i define the following value as conditional statement of form's text input value in this case so that the default value [FONT=Comic Sans MS](<?php echo $_POST($colors[0]);?> shall insert the default value "No Color Chosen")[/FONT] is inserted on blank form submission ?
value=
"<?php echo $_POST($colors[0]);?>"
"<?php echo $_POST($colors[1]);?>"
thanks,