Niet ingelogged

Gestart doorWouter7 reacties35 weergaven

8 berichten · pagina 1 van 1

Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Als ik inlog via dit script

<div class="post">
                    <h1 class="title"><a href="#">Login</a></h1>
                    <p class="byline"><small></a></small></p>
                    <div class="entry">
                        <p>[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR] 
    [COLOR= #FF8000]// Dit is niet mijn gewoonte om queries op deze manier in te springen, maar om de layout 
    // van Sitemasters niet naar de knoppen te helpen doe ik dit even gek :) [/COLOR]
     
    [COLOR= #0000BB]$qLogin[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id FROM gebruikers WHERE 
                gebruikersnaam = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" AND 
                wachtwoord     = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR] 
     
    [COLOR= #FF8000]// Met deze query selecteren we het gebruikers-id van de gebruikersnaam en controleren we of 
    // de account geactiveerd is in 1 keer. Als je deze niet snapt, lees hem dan 20 keer :) 
    // Je kan natuurlijk ook een tutorial over dit soort queries lezen, alhoewel 
    // ze poepsimpel zijn IMO. 
    // Deze query mag overigens geen resultaten opleveren om te mogen inloggen. Als deze 
    // wél een resultaat oplevert is de account nog niet geactiveerd (en bestaat de 
    // activatiedata dus nog). [/COLOR]
    [COLOR= #0000BB]$qActivatie[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(id) FROM gebruikers, gebruikers_activaties WHERE 
        gebruikers.gebruikersnaam = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" AND 
        gebruikers.id             = gebruikers_activaties.gebruikers_id"[/COLOR][COLOR= #007700]);[/COLOR] 
         
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qActivatie[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit account is nog niet geactiveerd.[/COLOR][COLOR= #007700]; 
    }[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qLogin[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De gebruikersnaam/wachtwoord combinatie is niet correct.[/COLOR][COLOR= #007700]; 
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] 
        [COLOR= #FF8000]// Alles ok, inloggen dus. 
        // Nu is 1 ding belangerijk: 
        // ZORG DAT ER EEN session_start() GEPLAATST IS, HETZIJ IN JE INDEX.PHP WAAR 
        // DEZE PAGINA IN GEPLAATS WORDT, HETZIJ BOVENAAN DEZE PAGINA (ALS ER GEEN 
        // INCLUDESYSTEEM IS)!!! [/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]]         =[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qLogin[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);[/COLOR] 
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]];[/COLOR] 
        [COLOR= #FF8000]// Mocht je nog andere data willen in je sessie,  
        // zoals een level, dien je dit hier te plaatsen. [/COLOR]
        ?> 
        Je bent succesvol ingelogged. Klik <a href="index.php?p=controlepaneel">hier</a> om naar je controlepaneel te gaan. 
        [COLOR= #0000BB]<?php[/COLOR] 
    [COLOR= #007700]} 
}[/COLOR] 
?> 
<form action="<?=htmlentities($_SERVER[REQUEST_URI])?>" method="post"> 
Gebruikersnaam:<br /> 
<input type="text" name="gebruikersnaam" /><br /> 
Wachtwoord:<br /> 
<input type="password" name="wachtwoord" /><br /> 
<br /> 
<input type="submit" value="Login" /> 
</form></p>
                    </div>
                </div>


Dan zegt het systeem dat ik succesvol ben ingelogged en stuurt me door naar

<div class="post">
                    <h1 class="title"><a href="#">ControlePaneel</a></h1>
                    <p class="byline"><small></a></small></p>
                    <div class="entry">
                        <p>[COLOR= #0000BB]<?php[/COLOR]  
[COLOR= #FF8000]// Zorg dat hierboven ERGENS session_start() staat!  [/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]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR]  
    [COLOR= #FF8000]// E-mailadres bijwerken:  
    // De variabele fout aanmaken om fouten ivm undefined variable te voorkomen  [/COLOR]
    [COLOR= #0000BB]$fout[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]  
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]  
        [COLOR= #FF8000]// Zelfde functie als bij registratie  
        // Een globale functies.php waarin je al je functies gooit is dus wel handig  [/COLOR]
        [COLOR= #007700]function[/COLOR] is_email[COLOR= #007700]([/COLOR][COLOR= #0000BB]$in[/COLOR][COLOR= #007700]) {[/COLOR]  
            [URL="http://www.php.net/list"]list[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$local[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$host[/COLOR][COLOR= #007700]) =[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]@[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$in[/COLOR][COLOR= #007700]);[/COLOR]  
            [COLOR= #0000BB]$pattern_local[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?).[/COLOR] 
                           [COLOR= #007700].[/COLOR] [COLOR= #DD0000]([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$[/COLOR][COLOR= #007700];[/COLOR]  
            [COLOR= #0000BB]$pattern_host[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?).([-]?)[/COLOR] 
                          [COLOR= #007700].[/COLOR] [COLOR= #DD0000][0-9a-z]*([-]?[0-9a-z]+)+)*.[a-z]{2,4}$[/COLOR][COLOR= #007700];[/COLOR]  
            [COLOR= #0000BB]$match_local[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pattern_local[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$local[/COLOR][COLOR= #007700]);[/COLOR]  
            [COLOR= #0000BB]$match_host[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pattern_host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$host[/COLOR][COLOR= #007700]);[/COLOR]  
        
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$match_local[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$match_host[/COLOR] [COLOR= #007700]?[/COLOR] true [COLOR= #007700]:[/COLOR] false[COLOR= #007700]);  
        }[/COLOR]      
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR]is_email[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])) {[/COLOR]  
            [COLOR= #0000BB]$fout[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Geen geldig e-mailadres![/COLOR][COLOR= #007700];  
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]  
            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE gebruikers SET  
                email = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"  
                WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]]);[/COLOR]  
                [COLOR= #FF8000]// Vervolgens moet de pagina vernieuwd worden.  [/COLOR]
                [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_URI[/COLOR][COLOR= #007700]]);  
        }  
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]  
        [COLOR= #FF8000]// Het formulier is nog niet verzonden, dus vullen we het veldje met het huidig e-mailadres  [/COLOR]
        [COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT email FROM gebruikers WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]]),[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]);  
    }[/COLOR]  
?>  
<h1>Welkom, <?=htmlentities($_SESSION[gebruikersnaam])?>!</h1>  
Wijzig je e-mailadres:  
<?=$fout?>  
<form action="<?=htmlentities($_SERVER[REQUEST_URI])?>" method="post">  
<input type="text" name="email" value="<?=htmlentities($email)?>" />  
<input type="submit" value="Bijwerken" /> 
</form> 
<a href="index.php?p=uitloggen" onclick="return confirm(Ben je zeker dat je wilt uitloggen?);">Uitloggen</a>  
[COLOR= #0000BB]<?php[/COLOR]  
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]  
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je bent niet ingelogged, klik <a href="index.php?p=login">hier</a> om dit te doen.[/COLOR][COLOR= #007700];  
}[/COLOR]  
?> </p>
                    </div>
                </div>


waar hij zegt dat ik niet ben ingelogged ?

Wat is er Fout?

~Wouter
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Heeft dit te maken met de cookies?
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
heb je bij allebij de paginas bovenin session start ?
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Sjoerd schreef:
heb je bij allebij de paginas bovenin session start ?
nee, maar ze worden geincluded door index.php en daar wel ( eigenlijk niet, maar als ik daar session_start(); zet, zegt hij : headers already sent
0
Berichten
1.294
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wouter schreef:
Eerdere citaten tonen
Sjoerd schreef:
heb je bij allebij de paginas bovenin session start ?
nee, maar ze worden geincluded door index.php en daar wel ( eigenlijk niet, maar als ik daar session_start(); zet, zegt hij : headers already sent
dan moet je session_start(); of helemaal bovenin zetten of session_start(); weg doen (backspace) clown
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Alexx schreef:
Eerdere citaten tonen
Wouter schreef:
Eerdere citaten tonen
Sjoerd schreef:
heb je bij allebij de paginas bovenin session start ?
nee, maar ze worden geincluded door index.php en daar wel ( eigenlijk niet, maar als ik daar session_start(); zet, zegt hij : headers already sent
dan moet je session_start(); of helemaal bovenin zetten of session_start(); weg doen (backspace) clown
session start staat er niet emo
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alexx schreef:
Eerdere citaten tonen
Wouter schreef:
Eerdere citaten tonen
Sjoerd schreef:
heb je bij allebij de paginas bovenin session start ?
nee, maar ze worden geincluded door index.php en daar wel ( eigenlijk niet, maar als ik daar session_start(); zet, zegt hij : headers already sent
dan moet je session_start(); of helemaal bovenin zetten of session_start(); weg doen (backspace) clown
niet weg doen,
dan werkt het zeker niet emo
gewoon helemaal bovenin dit zetten
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
?>


niks er voor, ook geen enter of spatie
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Sjoerd bedankt, het werkt
smile
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