Wie is online?

Gestart doorVandijkdesign38 reacties105 weergaven

39 berichten · pagina 3 van 3

Vandijkdesign

Lid · Topicstarter

Berichten
753
Reputatie
0
Punten
0,06
Lid sinds
Laatst gezien
Dit heb ik nu allemaal:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]functions.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// Sessie is verlopen, cookie niet[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]))
{[/COLOR]
    [COLOR= #FF8000]// Selecteer sessie op cookie [/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT uId,uName,uPass FROM member_accounts WHERE uId = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"SQL: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Array:FORUMCODE0"[/COLOR][COLOR= #007700];[/COLOR]

    [COLOR= #FF8000]// Als ip overeenkomt[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]SesIp[/COLOR][COLOR= #007700]])
    {[/COLOR]
        [COLOR= #FF8000]// Zetten we de sessie[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]SesId[/COLOR][COLOR= #007700]];    
    }    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #FF8000]// Als beide geset zijn[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]))
    {[/COLOR]
        [COLOR= #FF8000]// Als beide een waarde hebben [/COLOR]
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]))
        {[/COLOR]
            [COLOR= #FF8000]// Maar deze waardes niet overeenkomen[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]]) {[/COLOR]
                [COLOR= #FF8000]// Verwijder dan de gegevens[/COLOR]
                [COLOR= #007700]@[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM member_sessions WHERE uHash = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/session_destroy"]session_destroy[/URL][COLOR= #007700]();[/COLOR]
                [URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"uHash"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()-[/COLOR][COLOR= #0000BB]60[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]60[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]24[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]7[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]700[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #FF8000]// En refresh[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<meta http-equiv="refresh" content="0;url=index.php">[/COLOR][COLOR= #007700];   
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR] 
                [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT SesIp, SesId FROM member_sessions WHERE SesHash = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #0000BB]$sFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #FF8000]// Als ip of uId niet overeenkomt met de waades in de sessie[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](([/COLOR][COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]SesIp[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]]) || ([/COLOR][COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]SesId[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]))
                {[/COLOR]
                    [COLOR= #FF8000]// Deleten en refresh[/COLOR]
                    [COLOR= #007700]@[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM member_sessions WHERE uHash = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uHash[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                    [URL="http://www.php.net/session_destroy"]session_destroy[/URL][COLOR= #007700]();[/COLOR]
                    [URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"uHash"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()-[/COLOR][COLOR= #0000BB]60[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]60[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]24[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]7[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]700[/COLOR][COLOR= #007700]);[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<meta http-equiv="refresh" content="0;url=index.php">[/COLOR][COLOR= #007700];       
                }
            }
        }    
    }
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]))
{[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE member_accounts SET uLast = NOW() WHERE uId = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]);
}[/COLOR]
?>
En bij het welkomsbericht staat:
Spoiler tonen
<li><a href="#" class="user"><span class="bar">Welkom [COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/print_r"]print_r[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700]);[/COLOR]
?></span></a></li>
Wat is er fout?!
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En wat komt er nou uit:

print_r($_SESSION);
?>
confusedconfusedconfused
0
Vandijkdesign

Lid · Topicstarter

Berichten
753
Reputatie
0
Punten
0,06
Lid sinds
Laatst gezien
Aarclay schreef:
En wat komt er nou uit:

print_r($_SESSION);
?>
confusedconfusedconfused
Welkom Array ( [uHash] => 4626056296c9f96e743784008136481826dfa83bac60c25e4fd11570cc6b9bee [uId] => 4 )
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En:

print_r($sFetch);

Dit moet een array tonen, lijkt me met o.a je username ($sFetch[uName])
0
Vandijkdesign

Lid · Topicstarter

Berichten
753
Reputatie
0
Punten
0,06
Lid sinds
Laatst gezien
Aarclay schreef:
En:

print_r($sFetch);

Dit moet een array tonen, lijkt me met o.a je username ($sFetch[uName])
Nu krijg ik: Array ( [SesIp] => 145.53.193.214 [SesId] => 4 )
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Gebruik eens een andere var. voor die query op lijn 9, 11,13. Eentje waarmee je duidelijk maakt dat je de data uit je member-tabel ophaalt.

Want nu krijg je alle data uit je sessie-tabel.
0
Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alstu:

[COLOR= #0000BB]<?php                    
$gegevens_query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
        SELECT
            uId,
            uName
        FROM
            member_accounts
        WHERE
            uId = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]])
        )[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$gegevens_query[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
             [COLOR= #0000BB]$gegevens[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$gegevens_query[/COLOR][COLOR= #007700]);[/COLOR]
             [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$gegevens[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uName[/COLOR][COLOR= #007700]];
        }[/COLOR]
?>
0
Vandijkdesign

Lid · Topicstarter

Berichten
753
Reputatie
0
Punten
0,06
Lid sinds
Laatst gezien
Marjolein schreef:
Alstu:

[COLOR= #0000BB]<?php                    
$gegevens_query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
        SELECT
            uId,
            uName
        FROM
            member_accounts
        WHERE
            uId = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]])
        )[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$gegevens_query[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
             [COLOR= #0000BB]$gegevens[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$gegevens_query[/COLOR][COLOR= #007700]);[/COLOR]
             [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$gegevens[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uName[/COLOR][COLOR= #007700]];
        }[/COLOR]
?>
Helemaal top Marjolein, hartstikke bedankt! thumbsup
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En dat legde ik dus uit, dat je een andere variabele moest nemen wink
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren