Foros del Web » Programando para Internet » PHP »

Problema entre javascript y php

Estas en el tema de Problema entre javascript y php en el foro de PHP en Foros del Web. Buenas, vereis, tengo un problema y es que cree un formulario con INNERHTML con un input dentro de una funcion javascript y ese formulario apunta ...
  #1 (permalink)  
Antiguo 02/02/2011, 05:36
 
Fecha de Ingreso: noviembre-2010
Mensajes: 26
Antigüedad: 13 años, 5 meses
Puntos: 0
Problema entre javascript y php

Buenas, vereis, tengo un problema y es que cree un formulario con INNERHTML con un input dentro de una funcion javascript y ese formulario apunta a un archivo php.

El problema es que me da un error dificil de solventar, ya que dreamweaver no me dice que es un error de sintaxis, pero sin embargo, el parse error de php me dice que hay un error, que es el siguiente:

We selected 'Europe/Paris' for '1.0/no DST' instead in C:\Web\sesion.php on line 60 Notice: Undefined index: insertardeportes in C:\Web\sesion.php on line 60 Warning: main(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\Web\sesion.php on line 62 Fatal error: Call to undefined function alert() in C:\Web\sesion.php on line 62

Parte del codigo php:

insertardeportes es la id del input

Código PHP:
Ver original
  1. echo '<div align="right">';
  2.     echo "Este es el menu del usuario ". $_SESSION['nombre'] ."<br />\n";
  3.     echo 'Que quieres hacer?<br>
  4.     <strong><div id="capainsertar" style="cursor:pointer;" onClick="muestraformularioinsertar()">Insertar datos</div></strong>';
  5.     if ($_REQUEST['insertardeportes'] == "") //LINEA 60
  6.     {
  7.         alert("No has insertado nada en el campo deporte"); //LINEA 62
  8.     }
  9.    
  10.     echo '</div>';


Parte del codigo javascript:

Código Javascript:
Ver original
  1. function muestraformularioinsertar()
  2. {
  3.     if (document.getElementById("capainsertar").innerHTML.length == 14)
  4.     {
  5.         document.getElementById("capainsertar").innerHTML = "<FORM action=\"sesion.php\" id=\"insertardeportes\" onSubmit=\"borrarcapa(\"capainsertar\");\" >Dime el nombre de tu deporte favorito: <input type=\"text\" id=\"deporte\"> &nbsp <input type=\"submit\"> </FORM>";
  6.     }
  7. }
  8.  
  9. function borrarcapa(capa)
  10. {
  11.     document.getElementById(capa).innerHTML = "";
  12. }

Saludos.
  #2 (permalink)  
Antiguo 02/02/2011, 06:53
 
Fecha de Ingreso: febrero-2005
Mensajes: 187
Antigüedad: 19 años, 2 meses
Puntos: 2
Respuesta: Problema entre javascript y php

Lo que pasa es que si no esta definindo $_REQUEST['insertardeportes'], te va a salir el error diciendo q el index no esta definido:

Código PHP:
if ($_REQUEST['insertardeportes'] == ""
Deberias hacerlo asi:

Código PHP:
if ( ! isset($_REQUEST['insertardeportes'])) 
Asi lo que estas preguntando es que si no esta definido entre en la condicion.
__________________
___________________________
Hosting y Dominios en colombia
Blog de Cubica

Etiquetas: javascript
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 07:41.