Foros del Web » Programando para Internet » PHP »

Animacion

Estas en el tema de Animacion en el foro de PHP en Foros del Web. Saludos a todos, soy nuevo en el foro y tengo una duda que parece tonta pero no se como resolverla. Tengo 2 archivos, data.php y ...
  #1 (permalink)  
Antiguo 14/01/2011, 08:11
 
Fecha de Ingreso: enero-2011
Ubicación: Maracaibo
Mensajes: 179
Antigüedad: 13 años, 3 meses
Puntos: 2
Pregunta Animacion

Saludos a todos, soy nuevo en el foro y tengo una duda que parece tonta pero no se como resolverla.

Tengo 2 archivos, data.php y respaldar_data.php, lo cual me respalda la base de datos que yo seleccione, todo ese proceso lo hace correctamente.

Yo quiero que al momento de enviar el formulario me aparezaca una imagen que le indique al usuario que el respaldo se esta cargando (p.e. un gif animado) y luego mostrar el mesaje de que el respaldo se realizo correctamente.

Dejo el codigo aqui:

data.php

Código PHP:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Existencia de Productos</title>
        <link rel="stylesheet" type="text/css" href="css/estilos.css" />
            </head>
    <body>
    <?php
    
include("conex.php");
    
?>
    
    <div align="center"><strong> SELECCIONE LA BASE DE DATOS A RESPALDAR</strong> </div>
        <?php
           
           $result
=mysql_list_dbs();
           
        
?>
        <table width="400" border="0" align="center">     
        <tr>
        <form name='respaldo' method='post' action='respaldar_data.php' >
            <th width="150" scope="row" bordercolor="#F0F0F0" class="fondo"><label>Nombre del Respaldo:</label></th>
             <td colspan="6" align="center" bgcolor="#CCCCCC"><input name="backup" type="text" value="" size="25" maxlength="55" title="Nombre del Respaldo" class="inputboxInicio"  /><br/></td>
             <tr>
             <td colspan="3" align="center" bordercolor="#F0F0F0" class="fondo">
                 <label><strong> Base de Datos: </strong></label>
               <td width="139" bgcolor="#CCCCCC">
               <label> Datas: </label>
               </td>
             <td width="41">
           
              <select name = "datas" title="Datas">
                <?php 
                  
while ($resultado mysql_fetch_array($result))
                  {
                    
//$resultado[0] = 'Deportivos 2000';
                    
echo "<option value={$resultado['0']}>{$resultado['0']}</option>";
                  }
                  
mysql_free_result($result);
                
?>              
                </select>
                </td>
        </tr>
             <tr>
             <td colspan="7" bgcolor="#CCCCCC"><div align="right"> <input name="respaldar" type="submit" value="Respaldar" class="boton"  />
             
               
             </div></td>
             </tr>
          </form> 
         </tr>
        
             
        </table>
        
        
       </div>

</body>
</html>
respaldar_data.php

Código PHP:


<?php


$backup 
$_POST['backup'];
$data $_POST['datas'];
$fecha date("Y-m-d");

system("mysqldump -h localhost -u root $data > ../respaldos/".$backup."_".$fecha.".sql ");



echo 
"<script>alert('Respaldo Completado!')</script>";
echo 
"<script> window.history.back(-1) </script>";
?>
P.D.: Existe alguna manera de que al momento de darle al boton respaldar le permita al cliente guardar el respaldo en su PC??

Saludos y espero prota respuesta.
  #2 (permalink)  
Antiguo 14/01/2011, 09:00
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 19 años, 10 meses
Puntos: 834
Respuesta: Animacion

Tu pregunta tiene que ver más con javascript, pero probá reemplazar tus archivos de esta manera:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Existencia de Productos</title>
        <link rel="stylesheet" type="text/css" href="css/estilos.css" />
            </head>
    <body>
    <?php
    
include("conex.php");
    
?>
    
    <div align="center"><strong> SELECCIONE LA BASE DE DATOS A RESPALDAR</strong> </div>
        <?php
           
           $result
=mysql_list_dbs();
           
        
?>
        <table width="400" border="0" align="center">     
        <tr>
        <form name='respaldo' method='post' action='respaldar_data.php' onsubmit="document.getElementById('loading').style.visibility='visible'" target="pp">
            <th width="150" scope="row" bordercolor="#F0F0F0" class="fondo"><label>Nombre del Respaldo:</label></th>
             <td colspan="6" align="center" bgcolor="#CCCCCC"><input name="backup" type="text" value="" size="25" maxlength="55" title="Nombre del Respaldo" class="inputboxInicio"  /><br/></td>
             <tr>
             <td colspan="3" align="center" bordercolor="#F0F0F0" class="fondo">
                 <label><strong> Base de Datos: </strong></label>
               <td width="139" bgcolor="#CCCCCC">
               <label> Datas: </label>
               </td>
             <td width="41">
           
              <select name = "datas" title="Datas">
                <?php 
                  
while ($resultado mysql_fetch_array($result))
                  {
                    
//$resultado[0] = 'Deportivos 2000';
                    
echo "<option value={$resultado['0']}>{$resultado['0']}</option>";
                  }
                  
mysql_free_result($result);
                
?>              
                </select>
                </td>
        </tr>
             <tr>
             <td colspan="7" bgcolor="#CCCCCC"><div align="right"> <img id="loading" style="visibility:hidden" src="http://www.labuenamesa.carrefour.es/img/loading.gif" /><input name="respaldar" type="submit" value="Respaldar" class="boton"  />
             
               
             </div></td>
             </tr>
          </form> 
         </tr>
        
             
        </table>
        
        
       </div>
<iframe style="position:absolute; top:-15000px; width:0; height:0" name="pp"></iframe>
</body>
</html>
Código PHP:
<?php


$backup 
$_POST['backup'];
$data $_POST['datas'];
$fecha date("Y-m-d");

system("mysqldump -h localhost -u root $data > ../respaldos/".$backup."_".$fecha.".sql ");



echo 
"
<script>
top.document.getElementById('loading').style.visibility='hidden';top.alert('respaldo completado');
</script>"
;
?>
Como verás, agregamos una imagen con id loading, agregamos un iframe de nombre pp y al tag form le agregamos un target pp para que el formulario se submita al iframe, y también le agregamos al tag form un evento onsubmit para que muestre la imagen loading cuando el form sea enviado. Finalmente cambiamos el javascript del segundo archivo para que actúe sobre la ventana principal, que es donde el iframe está incluído.
  #3 (permalink)  
Antiguo 14/01/2011, 09:27
 
Fecha de Ingreso: enero-2011
Ubicación: Maracaibo
Mensajes: 179
Antigüedad: 13 años, 3 meses
Puntos: 2
Respuesta: Animacion

Muchas gracias Panino5001, me ha funcionado bien, solo hay que ajustarlo un poco para quede excelente.

Saludos

Etiquetas: animacion
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 16:28.