Foros del Web » Programando para Internet » PHP »

Mailing List "PROBLEMAS"

Estas en el tema de Mailing List "PROBLEMAS" en el foro de PHP en Foros del Web. saludos... estoy haciendo un mailing list... pero tngo un problema.. ingresa todo correectamente menos la parte de fecha de nacimiento.. me llega al sql 000-00-00 ...
  #1 (permalink)  
Antiguo 14/09/2007, 09:35
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Exclamación Mailing List "PROBLEMAS"

saludos... estoy haciendo un mailing list... pero tngo un problema.. ingresa todo correectamente menos la parte de fecha de nacimiento.. me llega al sql 000-00-00 no me llegan los datos ingresados... me gustaria q alguien checara el codigo y me dijera si ve algun error...
aqui les dejo
asi llega a la base de datos

Última edición por T4ke0veR; 14/09/2007 a las 10:13
  #2 (permalink)  
Antiguo 14/09/2007, 09:37
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Mailing List "PROBLEMAS"

Código PHP:
<?php require('Connections/mailinglist.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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"] == "form2")) {
  
$insertSQL sprintf("INSERT INTO registro (id, nombre, apellido, email, telefono, ciudad, fecha) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['telefono'], "int"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
                       
GetSQLValueString($_POST['fecha'], "date"));

  
mysql_select_db($database_mailinglist$mailinglist);
  
$Result1 mysql_query($insertSQL$mailinglist) or die(mysql_error());

  
$insertGoTo "mailreg.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_mailinglist$mailinglist);
$query_Recordset1 "SELECT * FROM registro ORDER BY nombre ASC";
$Recordset1 mysql_query($query_Recordset1$mailinglist) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>..// B A S I N G E R //..</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-image: url(imagenes/fondofondo.jpg);
}
.style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #686E4C;
}
.style2 {color: #A6AC88}
.style4 {color: #444444}
.style9 {color: #424530; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style10 {color: #A6AC88; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style11 {color: #94906D; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; }
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="estilos.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="760" border="0" cellspacing="0" cellpadding="0">
  <tr>
                      <tr>
                    <td width="73%">&nbsp;</td>
                    <td width="27%" rowspan="2" valign="top">&nbsp;</td>
                  </tr>
                  <tr>
                    <td valign="top"><table width="389" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="403" height="85" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td>&nbsp;</td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td><form id="form1" name="form1" method="post" action="">
                            </form>
                            
                              <form action="<?php echo $editFormAction?>" method="post" name="form2" id="form2">
                                <table align="center">
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Nombre:</td>
                                    <td><input type="text" name="nombre" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Apellido:</td>
                                    <td><input type="text" name="apellido" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Email:</td>
                                    <td><input type="text" name="email" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Telefono:</td>
                                    <td><input type="text" name="telefono" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Ciudad:</td>
                                    <td><input type="text" name="ciudad" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Fecha:</td>
                                    <td><label>
                                      <select name="fecha" id="fecha">
                                        <option>2007</option>
                                        <option>2006</option>
                                        <option>2005</option>
                                        <option>2004</option>
                                                                            </select>
                                      <select name="fecha" id="fecha2">
                                      <option>01</option>
                                      <option>02</option>
                                      <option>03</option>
                                      <option>04</option>
                                      </select>
                                      <select name="fecha" id="fecha3">
                                      <option>01</option>
                                      <option>02</option>
                                      <option>03</option>
                                      <option>04</option>
                                      </select>
                                    </label></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">&nbsp;</td>
                                    <td><input type="submit" value="Insert record" /></td>
                                  </tr>
                                </table>
                                <input type="hidden" name="id" value="" />
                                <input type="hidden" name="MM_insert" value="form2" />
                              </form>
                              <p>&nbsp;</p></td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td width="403"><table width="398" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              </html>
<?php
mysql_free_result
($Recordset1);
?>
asi va el codigo.. les deje lo basico .. pues el foro no me deja mas de 10000 caracteres
  #3 (permalink)  
Antiguo 02/10/2007, 13:38
 
Fecha de Ingreso: mayo-2006
Mensajes: 178
Antigüedad: 17 años, 11 meses
Puntos: 7
Re: Mailing List "PROBLEMAS"

El problema no lo tenes en el php, sino en el html.

Fijate que tenes 3 select que se llaman fecha, uno para el año, otro para el mes y otro para el dia.

1) Tenes que tener uno para cada valor.

2) Ponele un value a cada opcion: <option value="01">01</option>

3) Cuando ejecutes el form vas a tener que guardarte los datos de los 3 select en una misma variable para poder guardarlos en la base correctamente.

Se entendio?
  #4 (permalink)  
Antiguo 02/10/2007, 13:49
Avatar de @ndreX!  
Fecha de Ingreso: abril-2007
Mensajes: 161
Antigüedad: 17 años
Puntos: 4
Re: Mailing List "PROBLEMAS"

Exactamente como dice Jona77, arregla el HTML, y luego puedes ensamblarlo algo asi:

Código PHP:
<?
    $date 
$_POST['ano'].'-'.$_POST['mes'].'-'.$_POST['dia'];

/*
 P.D: Puedes facilitarte la vida con PHP :), de eso se trata
 El Formulario de fecha:
*/
    
echo '<select name="dia">';
    for(
$i=1;$i<=31;$i++){
        echo 
'<option value="'.$i.'">'.$i.'</option>';
    }
    echo 
'</select>';
    
    echo 
'<select name="mes">';
    for(
$i=1;$i<=12;$i++){
        echo 
'<option value="'.$i.'">'.$i.'</option>';
    }
    echo 
'</select>';
    
    echo 
'<select name="ano">';
    for(
$i=2004;$i<=date('Y');$i++){
        echo 
'<option value="'.$i.'">'.$i.'</option>';
    }
    echo 
'</select>';
?>
Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:53.