Problem with SESSION in php

1

Good people,

I am developing a login for my page but I have a problem that you are not saving me the data I want to give you.

Code

require_once("../gtm/bd/funcoes.php");
ligarBd();  

// Verifica se houve POST e se o usuário ou a senha é(são) vazio(s)
if (isset($_REQUEST['valida']) && $_REQUEST['valida']=="ok"){
    $sql="select * from users_social where fb_email='".$_REQUEST['user']."' and password='".sha1($_REQUEST['password'])."'";
    $query = mysql_query($sql);
    if(mysql_num_rows($query)==1){
        $row=mysql_fetch_array($sql);
        session_register("user_id","nome", "user_foto");
        $_SESSION = array();
        $_SESSION['user_id'] = $row['id'];
        $_SESSION['nome'] = $row['fb_nome'];
        $_SESSION['user_foto'] = $row['user_foto'];

        header("Location: http://sabeonde.pt/index.php");

    }
}

function ligarBd(){
    global $host, $bd, $user, $pass, $link;
    $link = mysql_connect($host, $user, $pass) or die ("Erro ao tentar abrir a base de dados". mysql_error());
    @mysql_select_db($bd);
}
    
asked by anonymous 02.02.2015 / 23:48

1 answer

1

Use:

$row=mysql_fetch_array($query);

instead of:

$row=mysql_fetch_array($sql);
    
03.02.2015 / 00:59