the following update form updates color preference of individual user in a password protected user area.
$disable_switch = '1';
//note: default value of $disable_switch= '0'; when user submits data using insert form primarily. when they update data using this update form the value changes to `1`
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formX")) {
$updateSQL = sprintf("UPDATE colortable SET color_name=%s, disable_switch=%s WHERE color_id=%s",
GetSQLValueString($_POST['color_name'], "text"),
GetSQLValueString(trim($disable_switch), "int"),
GetSQLValueString($_POST['color_id'], "int"));
mysql_select_db($database_XYZ, $XYZ);
$Result1 = mysql_query($updateSQL, $XYZ) or die(mysql_error());
$updateGoTo = "preference.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
exit ();
}
<form action="<?php echo $editFormAction; ?>" method="post" name="formX" id="formX">
<table align="center">
<tr valign="baseline">
<td align="right" nowrap="nowrap">Update 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_update" value="formX" />
<input type="hidden" name="color_id" value="<?php echo $query['color_id']; ?>" />
<input type="hidden" name="disable_switch" value="<?php echo "$disable_switch"; ?>" />
</td>
<td>
< ?php
$disabled = "disabled";
if (isset (which conditional statement shall disable the form permanently based on $disable_switch = '1'; ?)) {
echo "<input type='submit' value='Update Color' " . $disabled . "/>";
}else{
echo "<input type='submit' value='Update Color'/>";
}
?>
</td>
</tr>
</table>
</form>
by the way, i use the following mysql syntax to get the column values for disabling the submit button:
$query = "SELECT color_id, color_name, disable_switch FROM colortable WHERE color_id > 0 AND disable_switch = '1'";
what conditional php statement i should use to disable the form as indicated html portion of this post?
thanks,