Foros del Web » Programando para Internet » PHP »

Login en PHP

Estas en el tema de Login en PHP en el foro de PHP en Foros del Web. Buenas tardes!! Estoy armando algo en PHP para la facultad y estoy teniendo dificultades para implementar un sistema de login. En internet encontre muchisimas variantes, ...
  #1 (permalink)  
Antiguo 28/07/2012, 14:48
 
Fecha de Ingreso: julio-2012
Mensajes: 4
Antigüedad: 11 años, 8 meses
Puntos: 0
Pregunta Login en PHP

Buenas tardes!! Estoy armando algo en PHP para la facultad y estoy teniendo dificultades para implementar un sistema de login.
En internet encontre muchisimas variantes, trate de adaptar algunos, pero lo que yo necesito es algo mas simple. Algunos ejemplos incorporaban una interfaz grafica, decoraciones en CSS, javascript.. en fin.
Por otro lado, hubo dos ejemplos que no los pude adaptar, por una cosa u otra no funcionaban.

La BD que hice es la siguiente:

Nombre de BD: prueba
Tabla:usuarios

Campos:
Id_usuario
Nombre
Apellido
Clave
Mail
Función
Dependencia

Me podrian dar una ayuda con esto, ya sea con algun codigo simple que tengan o desarrollandolo a modo de ejemplo? Lo que quiero hacer es que la pantalla principal pida eso datos y si cumple, me redirija a otra. Muchas gracias! Un abrazo!
  #2 (permalink)  
Antiguo 28/07/2012, 15:03
Avatar de rodrigo791  
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 5 meses
Puntos: 168
Respuesta: Login en PHP

Y supongo que si estas estudiando te lo tienen que haber enseñado.
Si sabes hacer una BD entonces HTML por lo menos tenes que saber y ahi ya tenes los campos donde se ingresan datos, luego el tema ese de redireccionar usa header("Location: archivo") con eso redireccionas.
Usa variables de session para el login.http://www.php.net/manual/es/function.header.php
ahi tenes función header, y es un tema de hacer consultas también, si existen los datos en la BD entonces creas la session , sino haces lo que quieras, redireccionar, etc.
  #3 (permalink)  
Antiguo 28/07/2012, 15:36
 
Fecha de Ingreso: abril-2011
Ubicación: lima
Mensajes: 134
Antigüedad: 13 años
Puntos: 3
Respuesta: Login en PHP

<?php
include("conexion.php");
$cn=conectarDB();
$res=0;
$stm=$cn->prepare("select count(*) from usuarios where nombre=? and clave=?");
$stm->bind_param("ss",$_POST["usuario"],$_POST["clave"]);
$stm->execute();
$stm->bind_result($res);
$stm->fetch();

if ($res==1) {
session_start();
$_SESSION["usuario"]=$_POST["usuario"];
header("location: Bienvenido.php");
}

else{
header("location: index.php");
}

?>

conexion.php

<?php
function conectar_DB(){
$cn=new mysqli("localhost","root","mipassword","prueba");
if (mysqli_connect_errno()) {
echo 'Error al conectar a la base de datos'. mysqli_connect_errno();
exit();
}
return $cn;
}
?>

suerte...
__________________
Solitary wolf..[email protected]
  #4 (permalink)  
Antiguo 29/07/2012, 11:38
 
Fecha de Ingreso: julio-2012
Mensajes: 4
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Login en PHP

Cita:
Iniciado por rodrigo791 Ver Mensaje
Y supongo que si estas estudiando te lo tienen que haber enseñado.
Si sabes hacer una BD entonces HTML por lo menos tenes que saber y ahi ya tenes los campos donde se ingresan datos, luego el tema ese de redireccionar usa header("Location: archivo") con eso redireccionas.
Usa variables de session para el login.[url]http://www.php.net/manual/es/function.header.php[/url]
ahi tenes función header, y es un tema de hacer consultas también, si existen los datos en la BD entonces creas la session , sino haces lo que quieras, redireccionar, etc.
Gracias!! Pero no estudio informatica ni programacion. Estudio Administracion de Empresas y para hacer un TP nos pidieron que examinemos el sistema de informacion de una empresa y hagamos sugerencias y mejoras. Como parte de esas mejoras decidimos que seria bueno desarrollar algo en PHP. El problema es que ninguno sabe mucho, entonces leyendo y probando y demas, es que llegamos a hacer un ABM, a diseñar las bases de datos, la pagina web, entre otras cosas, todo de forma autodidacta. Nos faltan algunas cosas como hacer funcionar el login..pero ya va a salir!! Gracias por el dato rodrigo!
  #5 (permalink)  
Antiguo 29/07/2012, 11:41
 
Fecha de Ingreso: julio-2012
Mensajes: 4
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Login en PHP

Cita:
Iniciado por lincolnf_2 Ver Mensaje
<?php
include("conexion.php");
$cn=conectarDB();
$res=0;
$stm=$cn->prepare("select count(*) from usuarios where nombre=? and clave=?");
$stm->bind_param("ss",$_POST["usuario"],$_POST["clave"]);
$stm->execute();
$stm->bind_result($res);
$stm->fetch();

if ($res==1) {
session_start();
$_SESSION["usuario"]=$_POST["usuario"];
header("location: Bienvenido.php");
}

else{
header("location: index.php");
}

?>

conexion.php

<?php
function conectar_DB(){
$cn=new mysqli("localhost","root","mipassword","prueba");
if (mysqli_connect_errno()) {
echo 'Error al conectar a la base de datos'. mysqli_connect_errno();
exit();
}
return $cn;
}
?>

suerte...
Muchas gracias lincolnf_2 !
Ahora lo voy a probar a ver que onda. Un abrazo! Si logro que lo que estoy haciendo funcione lo subo!
  #6 (permalink)  
Antiguo 29/07/2012, 12:54
Avatar de rodrigo791  
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 5 meses
Puntos: 168
Respuesta: Login en PHP

Cita:
Iniciado por leguicri26 Ver Mensaje
Estudio Administracion de Empresas
No se si lo de realizar un programa en php lo decidieron ustedes o te lo exigieron , pero php no tiene NADA que ver con administracion de empresas, suerte con eso!
  #7 (permalink)  
Antiguo 30/07/2012, 05:13
 
Fecha de Ingreso: julio-2012
Mensajes: 4
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Login en PHP

Cita:
Iniciado por rodrigo791 Ver Mensaje
No se si lo de realizar un programa en php lo decidieron ustedes o te lo exigieron , pero php no tiene NADA que ver con administracion de empresas, suerte con eso!
No no, lo de PHP lo decidimos nosotros. Y si tiene mucho que ver. La empresa no tiene un registro ni de clientes ni de proveedores ni nada de eso. Al analizar el sistema de informacion y la forma de trabajar tan arcaica sugerimos hacerlo en PHP. Si sugeriamos que hagan un sistema en windows no iban a poder adaptarlo demasiado (siempre iban a estar atados a Microsoft). Osea.. todo tiene que ver con todo. La consigna incluye tambien presentar un bosquejo sobre como deberia funcionar ese sistema de informacion.. la diferencia es que nosotros fuimos un poco mas alla y estamos haciendo una prueba real y lo fuimos armando como pudimos. PHP no es solamente para paginas web o foros. Para un ABM y consultas para una pyme va de 10. Un abrazo!
  #8 (permalink)  
Antiguo 30/07/2012, 05:15
 
Fecha de Ingreso: julio-2012
Mensajes: 1
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Login en PHP

But the direction to go when you find yourself trapped in an overweight entire body? How do you shed pounds a balanced diet? And exactly what does it necessarily mean to free bodyweight in a very healthy way? To loose pounds in a healthy way method to enable your entire body to decompose fat as opposed to drinking water or muscle mass and also to sustain this weight-loss. If you appreciate to treat your system well, invest time to loosened fat. It can be healthful to unfastened all around 1 single lb a week by not implementing in additional than 1200 energy a day. Ultimately it's sensible to concentrate on a couple of weight every month. Overhasty diet plans or proceeding eager may to begin with result in shedding many excess fat rapidly, nevertheless, you reduce mineral water and lean muscle primarily. <a href=http://buyphen375.terapad.com>phen375</a> On the other hand, meals like fries, hamburgers along with other slimy your meals are not meant to be on your own food list in case you are taking sugar blockers. Gas and extra fat from these foods may still be stashed through your system and trigger morbid obesity. Weight reducers improve our system temperatures and cause the metabolic rate individuals system to rise. With a great metabolic process, our own bodies will are likely to shed fat at an increased rate.

We have all heard our justifiable share of weight loss tips prior to now. The unhealthy media is usually that most are merely myths. You might have maybe noticed an abundance of weight loss tips throughout the years. Possibly a person stated to beverage grapefruit fruit juice before each meal to stimulate your metabolic process or to load up around the black legumes since the fiber content will stop you from overindulging. http://buyphen375.terapad.com You'll be able to shed pounds in many ways, but as you now know, physical exercises need a lot of time unless you do the correct solutions, various other ways could be not quick enough, however, many aren't in reality safe and sound to go with over time. In this article we shall be dealing with the most common methods to lose weight fast. Among the best techniques to shed pounds is exercising. Hippocrates mentioned the simple truth medical practitioners must heal the full human body, not just for the ailment, and this can be done with work out. The most beneficial workouts for losing weight fast are cardio exercises which has a numerous power from reasonable to substantial. Bare in mind the exercises you do should be distinctive from another that will assist you not lose interest so fast and produce your knees and lower back continue to be unchanged. You will have one particular whether or not ensure shed pounds. That you were probably taught at school that nutrition really should include things like a good amount of higher-fiber content food like vegatables and fruits, various greens and bass and insane for unsaturated unwanted fat. Essentially the most talked over means of shedding pounds is to take diet pills a.

Etiquetas: autenticación, login
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 21:15.