
12/05/2010, 06:42
|
 | Colaborador | | Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 2 meses Puntos: 126 | |
Respuesta: Enviar formulario con fecha igual o inferior a la del servidor Hola
Prueba de esta manera Cita: <?php require_once('Connections/basedatos.php'); ?>
<?php $fecha_actual = strtotime(date("d-m-Y H:i:00",time()));
$fecha_limite = strtotime("11-5-2010 21:00:00");
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"] == "formulario1")) { if($fecha_actual > $fecha_limite){
echo "Limite pasado";
} else {
$insertSQL = sprintf("INSERT INTO bdprueba (nombre, apellido1, apellido2) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido1'], "text"),
GetSQLValueString($_POST['apellido2'], "text"));
mysql_select_db($database_basedatos, $basedatos);
$Result1 = mysql_query($insertSQL, $basedatos) or die(mysql_error());
$insertGoTo = "inicio.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo)); }
}
?> Suerte
__________________ Los formularios se envían/validan con un botón Submit <input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" /> |