login en php
-
Buenas.... nuevamente les vengo a traer una de mis dudas existenciales, hace 2 dias ke estoy tratando de sacar esto pero definitivamente sigo pensando ke me tengo ke dedicar al photoshop
bueno les cuento....
Tengo una base de datos que ya tiene una lista grosa de usuarios c/passwords, los cuales los tengo ingresados por medio de un foro phpbb. Mi problema es que no puedo lograr que me valide desde una pagina con un formulario, el nombre de usuario y contraseña para acceder a una page externa al foro (que deberia hacer uso de los mismos datos del registro). Me explico?
Necesito hacer eso de la forma mas segura posible. Cuento con un servidor c/ php/mysql bajo unix.
esta es la estructura que tengo en la base de datos:
base: MIEMBROS
..........|
..........|__ phpbb_users
........................|
........................|__ username
........................|
........................|__ user_password
........................|
........................|__ user_... etc etc....
necesito una mano con esto, si me pueden ayudar habrán hecho feliz a alguien
gracias por vuestro tiempo
saludos del vampiro ke trata de aprender php -
http://www.phpsecurepages.com/
Podés usar eso como base, si no me equivoco puede funcionar con una base de datos mysql pero deberías agregarle algo para que use MD5() con los passwords. -
Acá les dejo el codigo que estoy usando, tomé parte de securepages para completarlo.
### LOGIN.HTML ###Código:Untitled Document
### COMMON.PHP ###Código PHP:
$User = "usuario";
$Pass = "contraseña";
$Host = "localhost";
$DB = "miembros";
$Table = "phpbb_users";
?>
### LOGIN.PHP ###Código PHP:include("common.php");
if(!($link_id = mysql_connect($Host, $User, $Pass))) die(mysql_erorr());
mysql_select_db($DB);
/*This is were the actual log in takes place. We tell mysql to select the ID where the Name is exactly like the Name from the Form
where is Password is exactly like the encryption values of the password from the form.*/
$sql = "SELECT ID FROM " . $Table . " WHERE Name='" . addslashes($_POST['username']) . "' AND Password='" . md5($_POST['user_password']) . "' LIMIT 1";
if(!($result = mysql_query($sql))) die(mysql_error());
/*This is were we check the result. We check to see how many rows were in the result of the query. If there is 1 one row in the result, that means
there is one username with the right information, so that would mean they are logged in.*/
if(mysql_num_rows($result) == 1) {
/*Here we set a cookie that tells if the user has logged in and set it to last for a day. The cookie is used on the members page to check
If they cookie is there they can see the page, if not they can't.*/
setcookie("LoggedIn, TRUE, time()+(3600 * 24));
/*You could also do the header() here just like I explained before.*/
echo "Continue to the MEMBERS page.";
} else {
echo "Login failure";
}
?>
### MEMBERS.PHP ###Me tira un error cuando intento de logearme lo adjunto a continuacion:Código PHP:
/*If the cookie isset then they are logged in, else the scripts dies and says they are not logged in.*/
if(!isset($_COOKIE['LoggedIn'])) die("You are not logged in!");
/*Your content goes here. If it is php, keep it above the ?>. If it is HTML code, put below the ?> or you will get errors*/
?>
Parse error: parse error, unexpected T_CONTINUE in /www/cncgenerals.com.ar/login/login.php on line 22
El script lo tengo subido en la carpeta login. Y el problema me lo canta en la linea que tira el echo -
Te anda con lo que te dijo Slay?
Porque por lo que veo, en el login.php tenes la siguiente linea:y en el formulario de login.html tenes:Código PHP:$sql = "SELECT ID FROM " . $Table . " WHERE Name='" . addslashes($_POST['username']) . "' AND Password='" . md5($_POST['user_password']) . "' LIMIT 1";
o sea, los campos del formulario se llaman distintos a como los usas despues en el query, por lo tanto NUNCA te va a validar el usuario.Código:
