PHP - ingresar fechas en mysql con php

 
Vista:
sin imagen de perfil

ingresar fechas en mysql con php

Publicado por Sebastian (1 intervención) el 31/05/2016 05:24:18
hola tengo un formulario con el siguiente codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>INGRESAR PROVEEDORES CON FECHAS</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css">
</head>
 
<body>
 
<div class="group">
 
  <form action="registroconfecha.php" method="POST">
  <h2><em>Ingreso de Proveedores</em></h2>
 
 
      <label for="nombre">Nombre <span><em>(requerido)</em></span></label>
      <input type="text" name="nombre" class="form-input" required/>
 
      <label for="domicilio">DOMICILIO <span><em>(requerido)</em></span></label>
      <input type="text" name="domicilio" class="form-input" required/>
<label for="fechapapel">FECHA <span><em>(requerido)</em></span></label>
      <input type="text" name="txt_dia" size="4"class="form1-input">/
<input type="text" name="txt_mes" size="4" class="form1-input">/
<input type="text" name="txt_anio" size="4"class="form1-input">
 
      <label for="telefono">Telefono <span><em>(requerido)</em></span></label>
      <input type="text" name="telefono" class="form-input" />
     <center> <input class="form-btn" name="submit" type="submit" value="Ingresar" /></center>
    </p>
  </form>
 
</div>
</body>
by Sebastian Acuña
</html>

y este seria el archivo de proceso:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
 
$db_host="localhost";
$db_user="root";
$db_password="nemesis";
$db_name="mandrakephp";
$db_table_name="ingconfecha";
   $db_connection = mysql_connect($db_host, $db_user, $db_password);
 
if (!$db_connection) {
	die('No se ha podido conectar a la base de datos');
}
$subs_name = utf8_decode($_POST['nombre']);
$subs_last = utf8_decode($_POST['domicilio']);
$subs_email = utf8_decode($_POST['telefono']);
$a = utf8_decode($_POST['txt_dia']);
$b = utf8_decode($_POST['txt_mes']);
$c = utf8_decode($_POST['txt_anio']);
$fechadepapel= $c.$b.$a;
$resultado=mysql_query("SELECT * FROM ".$db_table_name." WHERE Email = '".$subs_last."'", $db_connection);
 
 
 
if (mysql_num_rows($resultado)>0)
{
 
header('Location: Fail.html');
 
} else {
 
	$insert_value = 'INSERT INTO `' . $db_name . '`.`'.$db_table_name.'` (`nombre` , `domicilio` , `telefono` , `fechadepapel` , `fechaderegistro` ) VALUES ("' . $subs_name . '", "' . $subs_last . '", "' . $subs_email . '", "' . $fechadepapel . '", "' NOW() '")';
 
mysql_select_db($db_name, $db_connection);
$retry_value = mysql_query($insert_value, $db_connection);
 
if (!$retry_value) {
   die('Error: ' . mysql_error());
}
 
header('Location: Success.html');
 
}
 
mysql_close($db_connection);
 
 
?>
y no me ingresa nada ni tira error, solo me aparece una pagina en blanco y no encuentro la falla alguien me podra dar una mano? soy autodidacta y algunas cosas no las puedo resolver solo perdonen las molestias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Víctor
Val: 152
Ha disminuido su posición en 6 puestos en PHP (en relación al último mes)
Gráfica de PHP

ingresar fechas en mysql con php

Publicado por Víctor (192 intervenciones) el 31/05/2016 09:06:08
Hola:

La linea 31 tiene un error de sintaxis. Debería ser:
1
$insert_value = 'INSERT INTO `' . $db_name . '`.`'.$db_table_name.'` (`nombre` , `domicilio` , `telefono` , `fechadepapel` , `fechaderegistro` ) VALUES ("' . $subs_name . '", "' . $subs_last . '", "' . $subs_email . '", "' . $fechadepapel . '", " NOW() )';

El error estaba al final de la linea.

Yo simplificaría la escritura a:
1
$insert_value = "INSERT INTO $db_name.$db_table_name ('nombre','domicilio','telefono','fechadepapel','fechaderegistro') VALUES ('$subs_name','$subs_last','$subs_email','$fechadepapel',NOW() )";

Saludos de Víctor.-
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar