Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/08/2009, 10:42
jozelui
 
Fecha de Ingreso: noviembre-2008
Mensajes: 25
Antigüedad: 15 años, 5 meses
Puntos: 0
Campo de texto que no puede ser null

Hola
Tengo pagina con un formulario php con dos campos uno validado con fecha y el otro texto, me gustaría que ambos campos pudiesen quedar vacíos al enviar el formulario, este es el código:
Código PHP:
<?php require_once('Connections/soloporhoy.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 soloporhoy (Fecha, Titulo) VALUES (%s, %s)",
                       
GetSQLValueString($_POST['date'], "date"),
                       
GetSQLValueString($_POST['title'], "text"));

  
mysql_select_db($database_soloporhoy$soloporhoy);
  
$Result1 mysql_query($insertSQL$soloporhoy) or die(mysql_error());

  
$insertGoTo "resultados.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
?>
¿me pueden orientar?