Ver Mensaje Individual
  #10 (permalink)  
Antiguo 30/04/2012, 15:48
afuentealba
 
Fecha de Ingreso: abril-2012
Mensajes: 65
Antigüedad: 12 años
Puntos: 0
Respuesta: No me graba datos del formulario a la base de datos

Cita:
Iniciado por GatorV Ver Mensaje
Código PHP:
Ver original
  1. // mal:
  2. @$pregunta=$_POST[$rowPreg['cod_idpregunta']];
  3. @$respuesta=$_POST['respuesta'];
  4. // bien:
  5. $pregunta = $_POST['cod_pregunta'];
  6. $respuesta = $_POST['respuesta'];

No es bueno usar @ para suprimir errores, mejor comprueba que exista la variable y así puedes manejar errores:

Código PHP:
Ver original
  1. if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) {
  2.         $pregunta = $_POST['cod_pregunta'];
  3.         $respuesta = $_POST['respuesta'];
  4.         $s="insert into respuestas(pregunta,respuesta) values('$pregunta','$respuesta')";
  5.         echo 'Your Data Inserted';
  6.         mysql_query($s) or die(mysql_error());
  7. }

Saludos.
Eres un genio viejo, gracias!

funcionando.

saludos!