Ver Mensaje Individual
  #7 (permalink)  
Antiguo 06/10/2008, 12:09
adibu
 
Fecha de Ingreso: septiembre-2007
Mensajes: 50
Antigüedad: 16 años, 7 meses
Puntos: 0
Respuesta: Problemas con la fecha

Estimado Jaronu.

Estoy seguro que tú respuesta es válida, lo malo es que o soy bastante novato en esto y no tengo ni idea de PHP ni SQL.

Manejo la base de datos desde PHPMyAdmin y el resto lo hago con Dreamweaver y de código no tengo ni idea.

Tengo el problema que no sé ni como entrar al código de la base de datos, así que no puedo hacer lo que me dices.

Me ha comentado una persona que igual se puede hacer algo desde la página del formulario que envía los datos a la base de datos, para que incluya la fecha del envío del formulario y quede reflejada en la base de datos.

Como datos te puedo decir que la TABLA se llama general

Tiene un campo que se llama fecha con el tipo DATE, que es el campo dónde debe incluirse la fecha del formulario.

La fecha la quiero en formato día(00) - mes(00) - año(0000)

El código de la página del formulario es:


<?php require_once('Connections/conexionreformas.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 general (`Nombre_ y _Apellidos`, Dirección, Teléfono, Email, `Plazo_ de_ inicio`, Localidad, Provincia, `Código_ postal`, Descripción, reforma) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Nombre_y_Apellidos'], "text"),
GetSQLValueString($_POST['Direccin'], "text"),
GetSQLValueString($_POST['Telfono'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Plazo_de_inicio'], "text"),
GetSQLValueString($_POST['Localidad'], "text"),
GetSQLValueString($_POST['Provincia'], "text"),
GetSQLValueString($_POST['Cdigo_postal'], "text"),
GetSQLValueString($_POST['Descripcin'], "text"),
GetSQLValueString($_POST['obra_realizar'], "text"));

mysql_select_db($database_conexionreformas, $conexionreformas);
$Result1 = mysql_query($insertSQL, $conexionreformas) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td width="232" align="right" nowrap>Nombre y Apellidos:</td>
<td> <div align="center">
<input type="text" name="Nombre_y_Apellidos" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Dirección:</td>
<td> <div align="center">
<input type="text" name="Direccin" value="" size="40">
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Teléfono:</td>
<td> <div align="center">
<input type="text" name="Telfono" value="" size="40">
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td> <div align="center">
<input type="text" name="Email" value="" size="40">
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Inicio de la obra:</td>
<td><div align="center">
<input type="text" name="Plazo_de_inicio" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Localidad de la obra:</td>
<td> <div align="center">
<input type="text" name="Localidad" value="" size="40">
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Provincia de la obra:</td>
<td><div align="center">
<input type="text" name="Provincia" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Código postal:</td>
<td><div align="center">
<input type="text" name="Cdigo_postal" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Obra a realizar:<br />
(Ej: Reformar piso) </td>
<td><div align="center">
<input name="obra_realizar" type="text" id="obra_realizar" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap>Descripci&oacute;n de la obra: </td>
<td><label>
<div align="center">
<textarea name="Descripcin" cols="34" rows="5" id="Descripcin"></textarea>
</div>
</label></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input name="submit" type="submit" value="Enviar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>



Si sabes el código que debo colocar y el lugar exacto dónde hacerlo, te lo agradecería un montón.

Saludos cordiales.