Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/07/2015, 10:03
sdantuoni
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 10 meses
Puntos: 2
Encriptacion MD5 para mi login web

Buenos dias gente de forosdelweb, hoy hice un cambio en mi web la cual estoy haciendo para un servidor de juegos multiplayer. En este caso uso 3 cosas conectadas a la misma db.

- El servidor de SAMP (Juego Multijugador)
- La web en PHP
- Foro SMF

Hice que el juego guardara las cuentas q son creadas en la misma tabla del foro smf, de manera que con solo crear 1 cuenta en el servidor ya se cree en el foro tambien.
Hasta aqui todo bien, le indique al servidor que guarde las contraseñas en MD5 para que el foro las pueda leer, con el foro anda todo genial, ahora el tema es que en la pagina web tengo una especie de UCP que me da estadisticas de los jugadores, cuando intente modificar el login de la web para que usara la base del smf me dio problemas ya que no consigo que lea la contraseña encriptada en MD5

Les dejo el codigo del login por aca
Código PHP:
<?php


include("config.php"); //including our config.php where is connecting to mysql...
session_start(); //starting session for profile.php (Dunno how to explain better) look little down
error_reporting(0); //without this we will always get some stupid notice that variable isn't defined....

$submit $_POST['submit']; //variable for submit button, in this variable we save button that player press in <input type='submit' name="submit" value='Login' />....
$username sanitize($_POST['username']); //variable for username, in this variable we save text that user type in <input type="text" name="username"....
$password sanitize($_POST['password']); //variable for password, in this variable we save text that user type in <input type="password" name="password"....

if($submit//if he press submit button
{    
    if(
$username && $password//if he type both of username and password not just one of them
    
{
        
$query mysql_query("SELECT member_name, passwd FROM smf_members WHERE member_name = '$username'"); //selecting user name and password, change it to your field names,  chage users to your table name, $username means username that he type...
        
if(mysql_num_rows($query) == 1//if user exists
        
{
            while(
$row mysql_fetch_assoc($query)) //loop thought table that we select in mysql_query
            
{
                
$dbusername $row['member_name']; //setting dbusername as variable from table, change 'username' to your field!
                
$dbpassword $row['passwd']; //setting dbpassword as variable from table, change 'password' to your field!
            
}
            if(
$username == $dbusername && $password == $dbpassword//if username is same as one from table and if password is the same as one from table...
            
{
                
$_SESSION['username'] = $dbusername//setting session username to one from table, this is useful if you login, that restart your browser and than you go in url where is your profile.php... Anyway this is useful :D
                
echo header('location: mi-cuenta.php'); //redirecting user to his profile page (profile.php)
            
}
            else echo 
"Wrong password!"//else if user type wrong password he will get this...
        
}
        else echo 
"Username doesn't exist!"//if username doesn't exist in table user will get this
    
}
    else echo 
"Type name and password!"//else if user doesn't type all fields he will get this...
}

?> 



<center><form action='entrar.php' method='POST'> 
<input type="text" name="username" value='<?php echo $username?>'/> 
<input type="password" name="password"/> 
<input type='submit' name="submit" value='Login' /> 
</form></center>
Sin encriptacion la contraseña la lee sin problemas pero ahora con la encriptacion MD5 no hay cristiano que lo haga entrar, les agradezco su ayuda. Saludos