Ver Mensaje Individual
  #9 (permalink)  
Antiguo 30/12/2011, 23:47
callesstone2
 
Fecha de Ingreso: diciembre-2011
Ubicación: Buenos aires
Mensajes: 14
Antigüedad: 13 años, 2 meses
Puntos: 0
Respuesta: Envio formulario con ajax

Código HTML:
Ver original
  1. <form onSubmit="Enviar(); return false" method="post">
  2. <Cuadro>
  3.     <izquierda>
  4.  
  5. Interprete:<br>
  6. <select id="Interprete">
  7. <? include("Select.php"); ?>
  8. Titulo<br>
  9. <input type="text" id="Titulo"  placeholder="Ingresa el nombre del disco" /><br>
  10. Caratula:<br>
  11. <input type="url" id="Imagen"   placeholder="Ingresa la url de la caratula"/><br>
  12. Año:<br>
  13. <input type="number" id="Ano"  placeholder="Año" /><br>
  14. Velocidad:<br>
  15. <input type="number" id="Velocidad"  placeholder="Velocidad" /><br>
  16. Servidor:<br>
  17. <input type="text" id="Servidor"  placeholder="Ej:Megaupload,rapidshare..."/><br>
  18. Sello:<br>
  19. <input type="text" id="Sello"  placeholder="El sello discografico" /><br>
  20. Descarga:<br>
  21. <input type="url" id="Descarga" placeholder="El link de descarga"/>
  22.  
  23. </izquierda>
  24.     <derecha id="Derecha">
  25.     Sitio solo para administradores y ayudantes.<br />
  26.     <hr align="left" width="600"  style="border:1px solid #666; opacity:0.6;"/>
  27.     Desde aqui usted podra añadir nuevas placas a los interpretes<br />
  28.     que ya esten en Suelas Embarradas.
  29.     <hr align="left" width="600"  style="border:1px solid #666; opacity:0.6;"/>
  30.     Por favor Complete el formulario de la izquierda para poder<br />
  31.     enviar y previsualizar.
  32.     <hr align="left" width="600"  style="border:1px solid #666; opacity:0.6;"/>
  33.     Se recomienda NO usar imagenes subidas a redes sociales<br> tales como : Facebook , ya que tienen Privacidad siendo imposible su uso
  34.     <hr align="left" width="600"  style="border:1px solid #666; opacity:0.6;"/>
  35.     Ultimos subidos:<br />
  36.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcRgKj1VUnHhWBQYr4lXk9iGp7dHsQGXW_zW1rx3xb8bkIj4_8x9ISZY9gU" width="25" height="25"  />
  37.     <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcT7MgFFGk-L_KzO19HkEXOP-QUd_m4gkrhLE_bu4JLOCJ42IEc8Af9jPA" width="25" height="25"  />
  38.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcReEOzJJmYWGu6oNM-Glf7iFSBh9HEDQVaq8QQu3gM0aK-DX_PEX33K6Q" width="25" height="25"  />
  39.     <img src="http://t1.gstatic.com/images?q=tbn:ANd9GcQAt-OpvPKfWDsBoHugBjtp7Sg5umfsa29NtDr7ejcNroysMVoAk6p0Xg" width="25" height="25"  />
  40.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcTLcEyKcDAv2RbY5S4gPWvdCEoOCz0k9tGNcNm7QHnfBBZA0lhdqJfqJhvv" width="25" height="25"  />
  41.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcQdSmR7qcEhE7WvD_nKxQDL5LZS9RS1WcXmZJO9edojTYcv_oOYZkNf20Y" width="25" height="25"  />
  42.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcSkI0kA_HL9fvabGqZ6r9mg8_cJ2NF4whc8xRjv22bi2NyoOjVa2BjWPg" width="25" height="25"  />
  43.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcRzwfOXgu2m6F2Ivr9BgHjegnNHiqIgXTRcl5KZekGv9LwZ7Lghj-TaZ5io" width="25" height="25"  />
  44.     <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcR5WdHy4xITurTseqKaSxLg3ZrwIYdxWZw1LFZ08UiBDkwA3Zrbr6VYNg" width="25" height="25"  />
  45.     <img src="http://t0.gstatic.com/images?q=tbn:ANd9GcT1wBuWv6Cy9b4Jz1YuqEMybKSUOxjj4RMV2grKjym8GuuuhnzFBe9sL7Q" width="25" height="25"  />...
  46.     </derecha>
  47. </Cuadro>
  48. <Estados id="Estados"></Estados>
  49. <Envio>
  50. <input type="submit" name="Enviar" value="Enviar"/>  <input type="button" onClick="Previsualizar(); return true;" value="Previsualizar" />
  51. </Envio>
  52. </form>

Ante la segura respuesta de que las etiquetas como <Estados> no sirven , hago la siguiente aclaracion : La pagina que estoy haciendo solo la hago para google chrome , ya se todos los problemas de compatibilidad con otros navegadores. Solo hago para chrome no cambiare esto.

y estas etiquetas funcionan ya que tengo otros codigos usandolos a la perfeccion.


Código Javascript:
Ver original
  1. function Enviar(){
  2.    
  3.     var id = document.getElementById('Interprete').value;
  4.     var Interprete1 = document.getElementById('Interprete').selectedIndex;
  5.     var Interprete = document.getElementById('Interprete').options[Interprete1].text;
  6.    
  7.     var Titulo = document.getElementById('Titulo').value;
  8.     var Ano = document.getElementById('Ano').value;
  9.     var Velocidad = document.getElementById('Velocidad').value;
  10.     var Servidor = document.getElementById('Servidor').value;
  11.     var Sello = document.getElementById('Sello').value;
  12.     var Descarga = document.getElementById('Descarga').value;
  13.     var Imagen  = document.getElementById('Imagen').value;
  14.  
  15.    
  16.     // --- Variables ajax
  17.     var ajax = new XMLHttpRequest();
  18.    
  19.     /* Estados */
  20.     ajax.onreadystatechange=function(){
  21.        
  22.         /* Si se esta cargando */
  23.         if(ajax.readyState==1 || ajax.readyState==2 || ajax.readyState==3){
  24.         document.getElementById('Estados').innerHTML='Procesando su peticion...';
  25.         }
  26.         /* Si se cargo */
  27.         if(ajax.readyState==4 && ajax.status==200){
  28.         document.getElementById('Estados').innerHTML=ajax.responseText;
  29.         }
  30.     }
  31.    
  32.     // --- Envios---
  33.     ajax.open("GET","Enviar.php?id="+id+"&Interprete="+Interprete+"&Titulo="+Titulo+"&Ano="+Ano+"&Velocidad="+Velocidad+"&Servidor="+Servidor+"&Sello="+Sello+"&Descarga="+Descarga+"&Imagen="+Imagen,true);
  34.  
  35.     ajax.send(null);
  36.    
  37. }



Código PHP:
Ver original
  1. // --- Conexion mysql ---
  2. $Conexion = mysql_connect('localhost','root','lamocosa');
  3. mysql_select_db('ajax',$Conexion);
  4.  
  5. // --- Variables ---
  6. $Id = $_GET['id'];
  7. $Interprete = $_GET['Interprete'];
  8. $Titulo = $_GET['Titulo'];
  9. $Ano = $_GET['Ano'];
  10. $Imagen = $_GET['Imagen'];
  11. $Velocidad = $_GET['Velocidad'];
  12. $Servidor = $_GET['Servidor'];
  13. $Sello = $_GET['Sello'];
  14. $Descarga = $_GET['Descarga'];
  15.  
  16. // --- Insercion mysql ---
  17. $Envio = mysql_query("INSERT INTO album (indentificador,id,Interprete,Imagen,Titulo,Ano,Velocidad,Servidor,Sello,Descarga, Usuarios,Valores,Megusta) VALUES ('','".$Id."','".$Interprete."', '".$Imagen."','".$Titulo."', '".$Ano."', '".$Velocidad."', '".$Servidor."', '".$Sello."', '".$Descarga."', '0', '0', '1');");
  18.  
  19. // --- Si Esta bien el envio ---
  20. if($Envio){
  21.     echo 'El album se acabo de crear vease';   
  22.     }
  23.  
  24.  
  25. // --- Cerrando mysql ---
  26. mysql_close($Conexion);