Ver Mensaje Individual
  #81 (permalink)  
Antiguo 28/12/2012, 06:49
consultashangar
 
Fecha de Ingreso: junio-2011
Ubicación: Buenos Aires
Mensajes: 91
Antigüedad: 13 años, 7 meses
Puntos: 1
Respuesta: sin acceso a bd al ingresra registros

Cita:
Iniciado por rodno Ver Mensaje
Buenas,

aqui te voy a mostrar un logeo simple de usuario:

login.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. require_once("config.php");
  4.  
  5. if (!empty($_POST["textUsuario"]) && !empty($_POST["textPass"]) && isset($_POST["btnLogin"]))
  6. {
  7.     $enlace=@mysql_connect($host,$db_user,$db_pass)or die(mysql_error());
  8.     mysql_select_db($database)or die(mysql_error());
  9.    
  10.     $sel=mysql_query("SELECT EMAIL FROM registro WHERE EMAIL = '".$_POST["textUsuario"]."' and CONTRASENA = '".$_POST["textPass"]."'");
  11.    
  12.     if (mysql_num_rows($sel) > 0) // esto es para saber si el usuario y contrasena fueron encontrados
  13.     {
  14.         session_start();
  15.         $_SESSION['Usuario'] = $_POST["textUsuario"];
  16.         header("location:index.php"); // aqui lo mando para la pagina principal donde estan van los usuarios autorizados
  17.        
  18.     }
  19.     else
  20.     echo 'Ha introducido mal el Usuario y/o Contraseña';   
  21.  
  22.    
  23. }
  24. ?>
  25. <html>
  26. <title>Login</title>
  27. <head>
  28. <link rel="stylesheet" href="sources/style.css" type="text/css">
  29. <link rel="stylesheet" href="sources/style_tab.css" type="text/css">
  30. </head>
  31. <body onload="javascript:document.formLogin.textName.focus();">
  32. <?php echo $msg_error;?>
  33. <br/>
  34.  
  35. <table class="loginForm" width="411" height="100" align="center" cellpadding="0" cellspacing="0" >
  36.  
  37.   <tr align="center">
  38.     <td width="403" ><h5>Logearse en el Sistema</h5></td>
  39.   </tr>
  40.   <tr>  
  41.     <td width="403" >
  42.    
  43. <form method="post"  name="formLogin" id="formLogin" action="login2.php">
  44.  
  45.    <table width="200" border="0" cellspacing="0" align="center" >
  46.     <tr >
  47.     <td>
  48.         <table class="Tables" width="100%">
  49.         <tr>
  50.            <td  colspan="2" align="center"><font size="4" color="navy"><strong>Entrar al Sistema</strong></font></td>
  51.            
  52.         </tr>
  53.         <tr>
  54.            <td><strong>Usuario</strong></td>
  55.            <td align="right"><input name="textUsuario" type="text" id="textUsuario" size="20" align="left" size="12"/></td>
  56.            <td></td>
  57.         </tr>
  58.         <tr>
  59.            <td><strong>Contraseña</strong></td>
  60.            <td align="right"><input name="textPass" type="password" id="textPass" size="20" maxlength="50" value="" align="left" size="12"/></td>
  61.            
  62.         </tr>
  63.         <tr >
  64.            <td  colspan="2" align="right">
  65.            <input name="btnLogin" type="submit" value="Acceder"/>
  66.            <input name="btnReset" type="reset" value="Limpiar"/>
  67.            </td>
  68.            
  69.         </tr>
  70.         </table>
  71.        
  72. </form>
  73. </td>
  74.            
  75.         </tr>
  76.         </table>
  77. </div>        
  78.  
  79. </body>
  80. </html>

Manana seguimos que tengo que irme del trabajo

Saludos
Ok Buenisimo por lo que veo debo modificar mi form en html de ingreso que tengo ya armado, lo estoy probando y va bien, ahora en el php deberia agregar que cuando el logeo esta ok, aparesca el nombre de usuario, que podria ser mail

Última edición por consultashangar; 28/12/2012 a las 07:10