Foros del Web » Programando para Internet » PHP »

Insertar hora de ingreso

Estas en el tema de Insertar hora de ingreso en el foro de PHP en Foros del Web. EL PROB ESSENCILLO O PUEDE INSERTAR EN MI RESGISTRO LA HORA EN Q EL USUARIOO INGRESA AL SISTEMA A PESAR DE QUE ME LO MUESTRA ...
  #1 (permalink)  
Antiguo 19/10/2009, 19:19
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Insertar hora de ingreso

EL PROB ESSENCILLO O PUEDE INSERTAR EN MI RESGISTRO LA HORA EN Q EL USUARIOO INGRESA AL SISTEMA A PESAR DE QUE ME LO MUESTRA EN EL RESULTADO DE LA CONSULTA.
AQUI BUSCO
Código PHP:
<?
session_start
();
include(
"include/bd.php");
include(
"include/functions.php");
bd_connect();




?>
<html>
<head>
    <head>
    <title>REGISTRO</title>
        <h1 ALIGN="center"></H1>
        
</head>


<script language="JavaScript" type="text/javascript">
function validaBusq() {
    if(document.frmPersonal.codigo.value == "" ) {
        alert("Debe ingresar su codigo de acceso");
        document.frmPersonal.codigo.focus();
        return false;
    }
    return true;
}

</script>
</head>
        
<body>
<?include ("cabecera.php");?>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;obj.height=40;obj.wmode="transparent";showClock(obj);</script>


<br>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="contenido_resutl2.php" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
    <td valign="top">
    
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center"><p class="clsLblTituloPagina">Ingreso</p></td>
        </tr>
        <tr>
            <td><hr></td>
        </tr>
        </table><br>
                
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td>Código:</td>
            <td><input type="text" name="codigo" value="<?echo $_GET['id_per']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        </table>
        
        <br>
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center">
                <input type="submit" name="Ingresar" value="Ingresar" class="clsSubmit">    



            </td>
        </tr>
        </table>
        
        <br>
        <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
              <td>
                <!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0 
                    src="pagina_blanco.php" frameborder=1 
                    width=100% scrolling=no height="170"></iframe>-->
                    
                        </tr>
                        <tr>
                            <td colspan="5" height="1" bgcolor="#000000"></td>
                        </tr>
                                                </table>
                        
                    </td>
                </tr>
                </table>
                </div>
                <??>

            </td>
        </tr>
          </table>
        
    </td>
</tr>
</table>
<font style="font-size:15px;"><SCRIPT LANGUAGE="Javascript"><!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Domingo','Lunes','Martes'Miércoles','Jueves','Viernes','S&aacute;bado');

// Array list of months.
var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)    {
    return (number < 1000) ? number + 1900 : number;
                                }

// Join it all together
today =  days[now.getDay()] + " " +
              date + " " +
              months[now.getMonth()] + " " +               
                (fourdigits(now.getYear())) ;

// Print out the data.
document.write("" +today+ " ");
  
//--></SCRIPT></font></td> 

<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
<?include("pie.php");?>
</body>
AQUI SALE ES RESULTADO
Código PHP:
<?
session_start
();
include(
"include/bd.php");
include(
"include/functions.php");
bd_connect();




?>
<html>
<head>
    <head>
    <title>REGISTRO</title>
        <h1 ALIGN="center"></H1>
        
</head>


<script language="JavaScript" type="text/javascript">
function validaBusq() {
    if(document.frmPersonal.codigo.value == "" ) {
        alert("Debe ingresar su codigo de acceso");
        document.frmPersonal.codigo.focus();
        return false;
    }
    return true;
}

</script>
</head>
        
<body>
<?include ("cabecera.php");?>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;obj.height=40;obj.wmode="transparent";showClock(obj);</script>


<br>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="contenido_resutl2.php" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
    <td valign="top">
    
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center"><p class="clsLblTituloPagina">Ingreso</p></td>
        </tr>
        <tr>
            <td><hr></td>
        </tr>
        </table><br>
                
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td>Código:</td>
            <td><input type="text" name="codigo" value="<?echo $_GET['id_per']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        </table>
        
        <br>
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center">
                <input type="submit" name="Ingresar" value="Ingresar" class="clsSubmit">    



            </td>
        </tr>
        </table>
        
        <br>
        <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
              <td>
                <!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0 
                    src="pagina_blanco.php" frameborder=1 
                    width=100% scrolling=no height="170"></iframe>-->
                    
                        </tr>
                        <tr>
                            <td colspan="5" height="1" bgcolor="#000000"></td>
                        </tr>
                                                </table>
                        
                    </td>
                </tr>
                </table>
                </div>
                <??>

            </td>
        </tr>
          </table>
        
    </td>
</tr>
</table>
<font style="font-size:15px;"><SCRIPT LANGUAGE="Javascript"><!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Domingo','Lunes','Martes'Miércoles','Jueves','Viernes','S&aacute;bado');

// Array list of months.
var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)    {
    return (number < 1000) ? number + 1900 : number;
                                }

// Join it all together
today =  days[now.getDay()] + " " +
              date + " " +
              months[now.getMonth()] + " " +               
                (fourdigits(now.getYear())) ;

// Print out the data.
document.write("" +today+ " ");
  
//--></SCRIPT></font></td> 

<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
<?include("pie.php");?>
</body>
Q CODIGO DEBO INGRESAR?????????
  #2 (permalink)  
Antiguo 19/10/2009, 19:47
 
Fecha de Ingreso: septiembre-2009
Ubicación: Neuquén
Mensajes: 142
Antigüedad: 14 años, 7 meses
Puntos: 12
Respuesta: Insertar hora de ingreso

Para manejar fechas, te conviene hacerlo con PHP, no con JavaScript... No es confiable ya que muchos usuarios lo desactivan... Con PHP simplemente utilizas date()

Te doy un ejemplo:

Código php:
Ver original
  1. <?php
  2.  
  3. $fechaDeHoy = date('d-m-Y');
  4. print $fechaDeHoy; // Imprime la fecha de hoy Ej.: 19-10-2009
  5.  
  6. ?>
  #3 (permalink)  
Antiguo 19/10/2009, 19:57
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Insertar hora de ingreso

Te entiendo perocomol ohago
QUIERO QUE LAFECHA QUEEEM MUESTRAELRESULTADO PSE AL MYSQL O AMI BASE DE DATOS :PERSONAL
  #4 (permalink)  
Antiguo 19/10/2009, 20:07
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 5 meses
Puntos: 20
Respuesta: Insertar hora de ingreso

debes hacer como te dice Nisrokh creas esa variable tal cual y donde hacer un insert para cargar los datos del usuario agregar el campo fecha con su variable, espero que te sirva, sino mostrame el codigo para php donde hacer la inserccion a la bd tuya, suerte
  #5 (permalink)  
Antiguo 19/10/2009, 20:13
 
Fecha de Ingreso: septiembre-2009
Ubicación: Neuquén
Mensajes: 142
Antigüedad: 14 años, 7 meses
Puntos: 12
Respuesta: Insertar hora de ingreso

Desconosco la forma en la que haces las consultas y tu base de datos... Pero yo por ej. Pero asi loa hago yo:
Este seria el campo de la fecha de la tabla...

fecha DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'

Armas la fecha:
Código php:
Ver original
  1. <?php
  2.  
  3. $fecha = date('Y-m-d h:i:s');
  4.  
  5. $link = mysql_connect('localhost', 'root', '', true);
  6. mysql_select_db('db', $link);
  7. mysql_query("INSERT INTO tabla VALUES ('{$fecha}')", $link);
  8.  
  9. ?>
  #6 (permalink)  
Antiguo 19/10/2009, 20:26
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Insertar hora de ingreso

bueno asi la hago


<?
session_start();
include("include/bd.php");
include("include/functions.php");
$cod=$_GET['codigo'];
bd_connect();



$personal= "SELECT id_per, paterno, materno, nombre, id_ope, direccion_ope, cargo, hora_entrada
FROM personal WHERE id_per = '$cod'
" . $sql_more . "
ORDER BY id_per";

//echo $personal;
$personal_query = db_query($personal);






?>


<html>
<head>
<title>REGISTRO</title>

</head>

<body>
<?include ("cabecera.php")?>
<H2 align="center"> DATOS DEL PERSONAL</H2>

<div style="height:280;width:100%;overflow:auto">
<table border="1" width="100%" cellpadding="1" cellspacing="1">
<tr>
<td valign="top">
<?
$i = 1;
while($personal = db_fetch_array($personal_query)) {
?>

<table border="0" width="100%" cellpadding="0" cellspacing="0" >
<td>
<tr> <td class="clsTituloTabla">Código</td>
<td><?echo $personal['id_per']?></td></tr>
<tr><td class="clsTituloTabla">Nombres</td>
<td ><?echo $personal['paterno'] . ' ' . $personal['materno'] . ' ' . $personal['nombre']?></td></tr>
<tr><td class="clsTituloTabla">id_ope</td>
<td ><?echo $personal['id_ope']?></td ></tr>
<tr><td class="clsTituloTabla">Oficina de Enlace</td>
<td ><?echo $personal['direccion_ope']?></td></tr>
<tr><td class="clsTituloTabla">Cargo</td>
<td ><?echo $personal['cargo']?></td></tr>
<tr><td class="clsTituloTabla">Hora</td>
<td ><?echo date('H:i:s',time() ) ?></td></tr>
<td aling="right"><? echo "<img src='" . $foto['imagen'] . "'>"?></td>
<td align="center" class="clsTituloTabla">&nbsp;</td>
</td>

<td //onMouseOver="this.className='dataTableRowSelected' " // onmouseout="this.className='dataTableRow'">



</td>
<td>
<td colspan="7" height="1" bgcolor="#000000"></td>
</td>
<?
$i++;
}
?>
</table>
<?


$Fecha= date('d-m-Y',time() - 21600 ); //le sumé horas
$Hora= date('H:i:s',time() ); //le sumé una hora

echo "Fecha: ".$Fecha;
//echo "<br>";
//echo "Su hora de ingreso ha sido: ".$Hora;
//echo "<br>";

?>
<?
if ($Hora >= date ('-8:10:00',time()+18000)){
echo "UD. LLEGO TARDE";
}
else{

echo "UD. LLEGO TEMPRANO";
}
?>
<script language=javascript>
</script>
<tr></td>
</tr>
</table>
<td align="center">
<td align="center">

<td align="bottom"><a href="index.php?>"><img border="0" src="images/regresar.gif">Regresar</a></td>

</td>
</tr>


</div>

</body>
</html>
  #7 (permalink)  
Antiguo 19/10/2009, 21:11
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 5 meses
Puntos: 20
Respuesta: Insertar hora de ingreso

bien pero aca no haces ningun insert ne tu bd, solo consulta, es asi???
  #8 (permalink)  
Antiguo 20/10/2009, 10:33
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Insertar hora de ingreso

Asi es ,es aqui doNde deseo hacer el insert ya que al hacer la consulTa quiero q esta hoRa que marca pase a la bd.
aL CONSULTAR MI RESULTADO MUESTRA LOS DATOS DEL NOMBRE DEL PERSONAL, SUCARG OY DONDE TRABAJA Y MUESTRA UNA HORA. esTA HORA ES LA QUEDESEO SE INSERTE EN MI BD DE LA MISMA TRABLA.
MI BD ES TIME ESE CAMPO, ESTACOMO 00:00:00 Y YO DESEARIA QUE AL HACER LA CONSULTA Y MOSTRAR EL RESULTADO ESTA CAMBIE A LA HORA QUE HICE LA CONSULTA
¿QUE INSERT DEBO AGREGAR?
YO HICE ESTE PERO NO CREO ESTE BIEN PORQ LO PUSE Y NADA, NO ME ALMECENO LA HORA DE INGRESO

$personal = mysql_query("INSERT INTO personal(id_per, paterno, materno, nombre,celular, telefono_fijo, direccion, fech_ingreso,
id_ope, direccion_ope,ind_personal, id_tipo, cargo, hora_entrada, hora_salida )
VALUES( '".$_POST['id_per']."','".$_POST['paterno']."', '".$_POST['materno']."','".$_POST['nombre']."',
'".$_POST['celular']."','".$_POST['telefono_fijo']."', '".$_POST['direccion']."', '" . date('Y-m-d H:i') . "',
'".$_POST['id_ope']."', '".$_POST['direccion_ope']."', 'S', '".$_POST['id_tipo']."', '".$_POST['cargo']."',
'" . date('Y-m-d H:i') . "', '". $Hora. "' , '". $Hora. "')");
//echo $personal;
//echo "Se registro su hora";
db_query($personal);

Última edición por lobbys; 20/10/2009 a las 10:43
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 03:38.