Guest User

Untitled

a guest
Aug 26th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. desde aqui es para iniciar session y guardad en la base de datos
  2. <?php
  3. require_once('../class/conexion.php');
  4. if($_SESSION['usuario'])
  5. {
  6.     header("Location: ../index.php");
  7. }
  8.  
  9. $usuario = $_POST['user'];
  10. $password = $_POST['pass'];
  11. $fecha = date("y-m-d");
  12. $hora = date("g:i:s a");//<-- variable de fecha que guardo
  13. $sql=mysql_query("SELECT * FROM user WHERE username='$usuario'",Conectar::con());
  14.  
  15. if ($f= mysql_fetch_array($sql))
  16. {
  17.     if($password == $f['pass'])
  18.         {
  19.            
  20.             $qry1 = "insert into sesiones values ('null','".$f['username']."','".$f['nombre']." ".$f['apellido']."','".$fecha."','".$hora."','".$f['lugar']."','".$f['id_user']."','".$f['id_perfil']."')";
  21.             if(mysql_query($qry1,Conectar::con()))
  22.             {
  23.             session_start();
  24.             $_SESSION['usuario'] = $f['username'];
  25.             $_SESSION['id_user'] = $f['id_user'];
  26.             $_SESSION['perfil']=$f['id_perfil'];
  27.             header("location: ../principal/");
  28.             }else{
  29.             header("location: ../index.php");      
  30.             }
  31.         }else
  32.         {
  33.             header("location: ../index.php?msg=2");
  34.         }
  35. }else
  36. {
  37.     header("location: ../index.php?msg=1");
  38. }  
  39.  
  40. ?>
  41. y de aqui comienza el codigo donde tengo la consulta
  42. <table width="100%" class="resultbus">
  43.                     <tr>
  44.                         <th>Usuario</th>
  45.                         <th>Nombre</th>
  46.                         <th>Fecha</th>
  47.                         <th>Hora</th>
  48.                         <th>Lugar</th>
  49.                     </tr>
  50.                  <?php
  51.                 $s = "select * from user where id_perfil = '".$_SESSION['perfil']."'";
  52.                 $r = mysql_query($s,Conectar::con());
  53.                 while($g= mysql_fetch_assoc($r))
  54.                 {
  55.                 ?>  
  56.                     <tr>
  57.                         <td align="center" class="t"><?php echo $g['username'];?></td>
  58.                         <td align="center" class="t"><?php echo $g['nombre'];?></td>
  59.                         <td align="center" class="t"><?php echo $g['fecha'];?></td>
  60.             <!--esta es la que no me muestrsa-->
  61.                         <td align="center" class="t"><?php echo $g['time'];?></td>
  62.                         <td align="center" class="t"><?php echo $g['lugar'];?></td>
  63.                     </tr>
  64.                 <?php
  65.                 }
  66.                 ?>    
  67.                 </table>
Add Comment
Please, Sign In to add comment