Foros del Web » Programando para Internet » PHP »

ayuda... tengo que hacer 2 veces click

Estas en el tema de ayuda... tengo que hacer 2 veces click en el foro de PHP en Foros del Web. hola amigos. tengo un problema.. cree un form que contiene un archivo que se puede adjuntar el problema es que no se porque... al ponerle ...
  #1 (permalink)  
Antiguo 27/10/2009, 10:21
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Pregunta ayuda... tengo que hacer 2 veces click

hola amigos.

tengo un problema.. cree un form que contiene un archivo que se puede adjuntar
el problema es que no se porque... al ponerle ok la primera vez en el form me queda el navegador "cargando".. pero no avanza....

si le hago nuevamente click al submit del form, me ingresa los valores, y me ingresa 2 registros, uno parcial (sin el archivo que estoy subiendo) y otro completamente ok...

espero me puedan ayudar.

este es el codigo php que ingresa los valores... al parecer el error es con el archivo que subo, pues si le elimino lo que tenga que ver con el archivo, ingresa altiro

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=ISO-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
    background-image: url(../imagenes/bg.jpg);
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
a:link {
    color: #FFFF00;
}
a:visited {
    color: #FFFF00;
}
a:hover {
    color: #FFFFFF;
}
a:active {
    color: #FFFF00;
}
.style13 {font-size: 12px; color: #FFFFFF; }
-->
</style>
<link href="../css.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div align="center">
  <table width="100%" height="50" border="0">
    <tr>
      <td valign="bottom"><div align="center" class="style13">
          <div align="center"><img src="http://www.forosdelweb.com/f18/imagenes/axiomalogo2.gif" alt="logo" width="211" height="75" /></div>
      </div></td>
      <td valign="bottom"><div align="center"><img src="http://www.forosdelweb.com/f18/imagenes/sga1.gif" alt="scc" width="480" height="43" /></div></td>
    </tr>
  </table>
  <table width="90%" border="0" bgcolor="#1C1C1C">
    <tr>
      <td><div align="center" class="titulo1">
          <?php

mysql_connect
("localhost""xxxx""xxxx"); 
mysql_select_db("administracion");

$nombre_reg=$_POST['nnombre'];
$rut_reg=$_POST['rrut'];
$institucion=$_POST['institucion'];
$nombre_curso=$_POST['nombre_curso'];

$ccc "http://localhost/admin_contrato/php/"//datos archivo
$directorio 'baseslicita/'//datos archivo


$nombre_archivo_capa $HTTP_POST_FILES["archivo_capa"]["name"]; //datos archivo
$tipo_archivo_capa $HTTP_POST_FILES["archivo_capa"]["type"]; //datos archivo
$tamano_archivo_capa $HTTP_POST_FILES["archivo_capa"]["size"]; //datos archivo
$nom_img_capatime().$nombre_archivo_capa//datos archivo
$nom_img_capa_sin_espacio str_replace(" """$nom_img_capa);
 

if(
move_uploaded_file($HTTP_POST_FILES['archivo_capa']['tmp_name'],$directorio $nom_img_capa_sin_espacio)) //datos archivo
{  $archivo_capacitacion$ccc $directorio $nom_img_capa_sin_espacio;  } //datos archivo

if ($_POST['institucion']=='' or $_POST['nombre_curso']==''
{
echo 
"<script>history.back(alert(\"Debes ingresar todos lo campos \"));</script>";  
}

else 
{
mysql_query("INSERT INTO capacitaciones (nombre_completo , rut , institucion , nombre_curso , archivo) VALUES ('$nombre_reg' , '$rut_reg', '$institucion', '$nombre_curso' ,'$archivo_capacitacion' )");

echo 
"Se ha ingresado un nuevo registro exitosamente<br>";
echo 
"Espera, se redireccionar&aacute; autom&aacute;ticamente";
?>
        <script language="JavaScript" type="text/javascript"> 
        setTimeout("url()",2500); 
        function url() 
        { 
        window.location="../administracion.php";
        } 
          </script>
        <?php 
}
?>
      </div></td>
    </tr>
    </table>
</div>
<p align="center">&nbsp;</p>
</body>
</html>

Última edición por icarocu; 27/10/2009 a las 10:33
  #2 (permalink)  
Antiguo 27/10/2009, 10:23
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: ayuda... tengo que hacer 2 veces click

mysql_connect("localhost", "editame", "editame"); <- edita eso .. nunca des informacion personal
2.- postea el html con el form me tinca mas que esta ahi el problema :B
  #3 (permalink)  
Antiguo 27/10/2009, 10:25
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: ayuda... tengo que hacer 2 veces click

Código javascript:
Ver original
  1. <script language="JavaScript" type="text/javascript">
  2.         setTimeout("url()",2500);
  3.         function url()
  4.         {
  5.         window.location="../administracion.php";
  6.         }
  7.           </script>
cual seria la funcionalidad de eso?
  #4 (permalink)  
Antiguo 27/10/2009, 10:33
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: ayuda... tengo que hacer 2 veces click

Cita:
Iniciado por Hidek1 Ver Mensaje
Código javascript:
Ver original
  1. <script language="JavaScript" type="text/javascript">
  2.         setTimeout("url()",2500);
  3.         function url()
  4.         {
  5.         window.location="../administracion.php";
  6.         }
  7.           </script>
cual seria la funcionalidad de eso?

eso es un javascript, que despues de 2,5 segundos, me redirije a la pagina "adminstracion.php"
  #5 (permalink)  
Antiguo 27/10/2009, 10:35
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: ayuda... tengo que hacer 2 veces click

postea el html :B
  #6 (permalink)  
Antiguo 27/10/2009, 10:36
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: ayuda... tengo que hacer 2 veces click

Hidek1...

este es el html que contiene el form

Código PHP:
<?php
session_start
();
//antes de hacer los cálculos, compruebo que el usuario está logueado
//utilizamos el mismo script que antes
if ($_SESSION["autentificado"] != "SI") {
//si no está logueado lo envío a la página de autentificación
header("Location: index.html");
} else {
//sino, calculamos el tiempo transcurrido
$fechaGuardada $_SESSION["ultimoAcceso"];
$ahora date("Y-n-j H:i:s");
$tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada));

//comparamos el tiempo transcurrido
if($tiempo_transcurrido >= 60 30 /*<----minutos*/) {
//si pasaron 10 minutos o más
session_destroy(); // destruyo la sesión
header("Location: index.html"); //envío al usuario a la pag. de autenticación
//sino, actualizo la fecha de la sesión
}else {
$_SESSION["ultimoAcceso"] = $ahora;
}
}
/// if(!isset($_SESSION['s_username']))header("location: ../index.html");     

?>

<?php
if ($_POST['nom_capacita']=='Elegir personal por nombre' and $_POST['rut_capacita']==''
{
echo 
"<script>history.back(alert(\"Por favor selecciona la persona a la cual deseas modificar el perfil.\"));</script>";
}
?>

<!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>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("¿ Agregar Capacitación con los datos ingresados. ?");
if (r==true)
  {
  document.form1.submit();
  }
else
  {
  location.href='add_propuesta.php';
  }
}
</script>

<TITLE>:: xxxx - Sxxxxxxxxx ::</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<!-- ImageReady Preload Script (index.psd) -->
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>JS Calendar (positioning test)</title>
    <style type="text/css"> 
    body {
    background-image: url(imagenes/bg.jpg);
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
a:link {
    color: #FFFF00;
}
a:visited {
    color: #FFFF00;
}
a:hover {
    color: #FFFFFF;
}
    </style>


    <link href="css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
<!--
.style13 {font-size: 12px; color: #FFFFFF; }
.style4 {font-size: 14px; color: #FFFFFF;}
.style15 {color: #FFFF00; font-size: 12px; }
-->
    </style>
</head>

<body>
<table width="100%" height="50" border="0">
  <tr>
    <td valign="bottom"><div align="center" class="style13">
      <div align="center"><img src="imagenes/logo.gif" alt="logo" width="211" height="75" /></div>
    </div></td>
    <td valign="bottom"><div align="center"><img src="imagenes/sga1.gif" alt="scc" width="480" height="43" /></div></td>
  </tr>
</table>
<div align="center"><br />
  <table width="90%" border="0" cellpadding="3" cellspacing="0" bgcolor="#1C1C1C" class="texto_1">
    <tr>
      <td><a href="administracion.php"> Volver al men&uacute; principal </a></td>
      <td width="50%"><div align="right"><a href="php/salir.php">X Cerrar sesi&oacute;n </a></div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>

    <tr>
      <td width="50%" bgcolor="#A2AB9E"><div align="right" class="texto_3"><strong>Buscar Personal por Nombre o R.U.T : </strong></div></td>
      <td bgcolor="#A2AB9E"><label></label>
        <form id="form2" name="form2" method="post" action="add_capacitacion_personal.php">
          <label></label>
          <label></label>
          <table border="0">
            <tr>
              <td><div align="right">
                <select name="nom_capacita" id="nom_capacita" >
                  <option selected="selected">Elegir personal por nombre</option>
<?php

$conexion
mysql_connect("localhost","xxxx","xxxxx") or die ("no se pudo conectar con el servidorssssssss");
mysql_select_db("administracion",$conexion)or die ("problemas en la conexion a la base de datos");

$adjudicamysql_query("select nombre_completo from personal order by nombre",$conexion) or die ("cago".mysql_error());

while (
$reg=mysql_fetch_array($adjudica)) 
echo 
"<option value=\"$reg[nombre_completo]\">$reg[nombre_completo]</option>"

?>
                </select>
              </div></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><div align="right">
                <input name="rut_capacita" type="text" id="rut_capacita" size="12" />
              </div></td>
              <td><input type="submit" name="Submit3" value="Buscar" /></td>
            </tr>
          </table>
        </form>      </td>
    </tr>
  </table>
<?php
$informacion
mysql_query("select * from personal where nombre_completo='$_POST[nom_capacita]' or rut='$_POST[rut_capacita]'",$conexion) or die ("cago".mysql_error());

if(
$reg=mysql_fetch_array($informacion));
{
    
$nombre=$reg["nombre_completo"];
    
$rut=$reg["rut"];

}
?>

</div>
<form action="php/php_add_capacitacion_personal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <div align="center">
    <table width="90%" border="0" bgcolor="#1C1C1C" class="texto_1">
      <tr>
        <td colspan="2" bgcolor="#333333" class="style4">Agregar experiencia laboral Sr.(a) : <span class="style15">

<?php 

echo "$nombre" ", " ;     
     
function 
formateo_rut($rut_param){ 
     
        
$parte4 substr($rut_param, -1); // seria solo el numero verificador 
    
$parte3 substr($rut_param, -4,3); // la cuenta va de derecha a izq  
    
$parte2 substr($rut_param, -7,3);  
        
$parte1 substr($rut_param0,-7); //de esta manera toma todos los caracteres desde el 8 hacia la izq 

    
return $parte1.".".$parte2.".".$parte3."-".$parte4

}
echo 
formateo_rut($rut);
?>
        
        </span></td>
      </tr>
      <tr>
        <td width="28%">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td colspan="2" bgcolor="#333333"><div align="center" class="style15">Capacitaciones registradas </div></td>
      </tr>
    </table>

<table width="90%" border="0" bgcolor="#1C1C1C" class="texto_1" cellspacing="4" >
<?php
// funcion cambiar formato fecha
function cambiarFormatoFecha($fecha){ 
    list(
$anio,$mes,$dia)=explode("/",$fecha); 
    return 
$mes."-".$anio
    
//return $dia."-".$mes."-".$anio; 

// Fin funcion

//where nom_contrato='$_POST[nom_contrato]' order by fecha_modificacion
$result=mysql_query("select * from capacitaciones where rut='$rut' or nombre_completo='$nombre' ");  



echo 
"<tr align='center' bgcolor='#333333'><td><strong>Institución</strong></td><td><strong>Curso Capacitación</strong></td><td><strong>Archivo</strong></td></tr>";
for (
$i 0$i mysql_num_rows($result); ++$i)
{
$columna mysql_fetch_row($result);  
if (
$columna[5]!="")
    {
    
$link="Certificado Capacitación";
    }
    
echo 
"<tr><td align='center'>$columna[3]</td><td align='center'>$columna[4]</td><td align='center'><a href='$columna[5]' target='_blank'>$link</a></td></tr>"


?>
</table>
    <table width="90%" border="0" bgcolor="#1C1C1C" class="texto_1">
      <tr>
        <td colspan="3" bgcolor="#333333"><div align="center" class="style15">Agregar datos </div></td>
      </tr>
      <tr>
        <td width="28%"><div align="right">Institucion : </div></td>
        <td colspan="2"><label>
          <input name="institucion" type="text" id="institucion" size="40" />
        </label></td>
      </tr>
      <tr>
        <td><div align="right">Nombre Capacitaci&oacute;n:</div></td>
        <td colspan="2"><label>
          <input name="nombre_curso" type="text" id="nombre_curso" size="40" />
        </label></td>
      </tr>
      <tr>
        <td><div align="right">Archivo : </div></td>
        <td colspan="2"><label>
          <input name="archivo_capa" type="file" class="texto_1" id="archivo_capa" />
        </label></td>
      </tr>
      <tr>
        <td><div align="right"></div></td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td width="21%"><label>
          <input type="reset" name="Reset" value="Limpiar formulario" />
        </label></td>
        <td><input type="button" class="rojo" onClick="show_confirm()" value="AGREGAR EXPERIENCIA"></td>
      </tr>
      <tr>
        <td><div align="right"></div></td>
        <td colspan="2"><input name="nnombre" type="hidden" id="nnombre" value="<?php echo $nombre ;?>" />
        <input name="rrut" type="hidden" id="rrut" value="<?php echo $rut ;?>" /></td>
      </tr>
    </table>  
  <br />
  </div>
</form>
</body>
</html>
  #7 (permalink)  
Antiguo 27/10/2009, 10:40
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: ayuda... tengo que hacer 2 veces click

show_confirm() <-- el codigo de ese script?
  #8 (permalink)  
Antiguo 27/10/2009, 10:44
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: ayuda... tengo que hacer 2 veces click

Cita:
Iniciado por Hidek1 Ver Mensaje
show_confirm() <-- el codigo de ese script?
es este

<script type="text/javascript">
function show_confirm()
{
var r=confirm("¿ Agregar Capacitación con los datos ingresados. ?");
if (r==true)
{
document.form1.submit();
}
else
{
location.href='add_propuesta.php';
}
}
</script>

y lo que hace es que crea una ventana al dar submit al form "form1", para confirmar que se desea continuar.. si se da ok... continua al php .. de lo contrario, redirige a la pagina "add_propuesta.php"
  #9 (permalink)  
Antiguo 27/10/2009, 10:46
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: ayuda... tengo que hacer 2 veces click

Cita:
Iniciado por Hidek1 Ver Mensaje
show_confirm() <-- el codigo de ese script?
¿no saber ver o leer con calma??

viene en el ultimo mensaje que te han colocado...
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #10 (permalink)  
Antiguo 27/10/2009, 10:48
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: ayuda... tengo que hacer 2 veces click

No entiendooooo !!!!

Sin hacer nada funciona.. No entiendo que pudo pasar
  #11 (permalink)  
Antiguo 27/10/2009, 10:52
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: ayuda... tengo que hacer 2 veces click

:O te juro que revise como 4 veces y no lo vi x'D debo estar poseido por la cafeina ...

si se soluciono sin hacer nada debes ser usuario de wintendo y bill estaba maneando tu pc XD!

saludos!
  #12 (permalink)  
Antiguo 27/10/2009, 10:56
Avatar de Fairy_Boy  
Fecha de Ingreso: octubre-2009
Ubicación: Kokiri Forest
Mensajes: 235
Antigüedad: 14 años, 6 meses
Puntos: 5
Respuesta: ayuda... tengo que hacer 2 veces click

Wintendo xD
mi profe decia asi hahahah
  #13 (permalink)  
Antiguo 27/10/2009, 11:03
 
Fecha de Ingreso: diciembre-2008
Mensajes: 268
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: ayuda... tengo que hacer 2 veces click

Cita:
Iniciado por hidek1 Ver Mensaje
:o te juro que revise como 4 veces y no lo vi x'd debo estar poseido por la cafeina ...

Si se soluciono sin hacer nada debes ser usuario de wintendo y bill estaba maneando tu pc xd!

Saludos!
wintendo ???

En todo caso trabajo en mac. No pc
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 12:29.