Buenos días, tengo realizado un formulario de Update y necesito que al tildar el checkbox "fecha_inicio" se inserte en la base la fecha y hora del sistema y al tildar el checkbox "fecha_fin" también.
Le paso el fragmento de código del formulario de Update:
Código PHP:
Ver original<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<input name="fecha_inicio" id="fecha_inicio" type="checkbox" value="Inicio" />
<input name="fecha_fin" id="fecha_fin" type="checkbox" value="Inicio" />
<input type="image" src="../assets/img/btn_guardar_gestionar.jpg" />
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_rs_detalle['id']; ?>" />
</form>
El fragmento de código del Update:
Código PHP:
Ver originalif ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE presupuestos SET fecha_inicio=%s, fecha_fin=%s WHERE id=%s", GetSQLValueString($_POST['fecha_inicio'], "text"),
GetSQLValueString($_POST['fecha_fin'], "text"),
GetSQLValueString($_POST['id'], "int"));
Y el código completo por las dudas:
Código PHP:
Ver original<?php require_once('../assets/Connections/cnx_m.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE presupuestos SET fecha_inicio=%s, fecha_fin=%s WHERE id=%s", GetSQLValueString($_POST['fecha_inicio'], "text"),
GetSQLValueString($_POST['fecha_fin'], "text"),
GetSQLValueString($_POST['id'], "int"));
$updateGoTo = "ok.php";
if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ?
"&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING'];
}
}
$colname_rs_detalle = "-1";
if (isset($_GET['id'])) { $colname_rs_detalle = $_GET['id'];
}
$query_rs_detalle = sprintf("SELECT * FROM presupuestos WHERE id = %s", GetSQLValueString
($colname_rs_detalle, "int")); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<input name="fecha_inicio" id="fecha_inicio" type="checkbox" value="Inicio" />
<input name="fecha_fin" id="fecha_fin" type="checkbox" value="Inicio" />
<input type="image" src="../assets/img/btn_guardar_gestionar.jpg" />
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_rs_detalle['id']; ?>" />
</form>
</body>
</html>
<?php
?>
Me podrán orientar como debo plantearlo?
Muchas gracias!