[PHP] Sessies werken niet

Gestart doorEpichotel2 reacties24 weergaven

3 berichten · pagina 1 van 1

Epichotel

Lid · Topicstarter

Berichten
69
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hi,

Als ik inlog met een bestaand account in mijn script, dan zegt hij dat hij succesvol is ingelogd, zonder enkele error. Maar nee, toch niet. Ik vermoed dat het een fout in de sessies is, kan iemand me helpen?

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL] [COLOR= #DD0000]templates/Default/top.php[/COLOR][COLOR= #007700];[/COLOR]
?>
    <h1>Inloggen</h1>
    [COLOR= #0000BB]<?php[/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]uid[/COLOR][COLOR= #007700]])) 
        {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">Je bent al ingelogd, het is niet mogelijk om nog eens in te loggen.</div>[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]]))
            {[/COLOR]
                [COLOR= #0000BB]$userQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username = "[/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]username[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
                [COLOR= #0000BB]$userFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userQuery[/COLOR][COLOR= #007700]);[/COLOR]
            
                [COLOR= #0000BB]$getUserReg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username = "[/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]username[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/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]$getUserReg[/COLOR][COLOR= #007700]) ===[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) 
                {[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">De ingevoerde gebruikersnaam bestaat niet, probeer een correcte gebruikersnaam in te voeren.</div>[/COLOR][COLOR= #007700];[/COLOR]
                    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]banned[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
                {[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">Je bent verbannen van de website, het is niet mogelijk om in te loggen.</div>[/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]))
                {[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">Je hebt niet alle velden ingevoerd, wees er zeker van dat je alle velden hebt ingevoerd.</div>[/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
                    [COLOR= #0000BB]$userReg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getUserReg[/COLOR][COLOR= #007700]);[/COLOR]
                    [COLOR= #0000BB]$regPassword[/COLOR] [COLOR= #007700]=[/COLOR] geo1[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
                    
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userReg[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$regPassword[/COLOR][COLOR= #007700]) 
                    {[/COLOR]
                        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$userReg[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
                        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$userReg[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]

                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="success">Je bent succesvol ingleogd, klik <a href="index.php">hier</a> om naar de index te gaan.</div>[/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]<div class="error">Het ingevoerde wachtwoord komt niet overeen met het wachtwoord van het account.</div>[/COLOR][COLOR= #007700];[/COLOR]
                        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];
                    }
                }
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
    ?>
    <form method="POST" action="">
        <label for="username">Gebruikersnaam:</label><br />
        <input class="input" type="text" name="username" /><br /><br />
        
        <label for="password">Wachtwoord:</label><br />
        <input class="input" type="password" name="password" /><br /><br />
        
        <input class="input" type="submit" value="Inloggen" name="login" />
    </form>
[COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}
        }[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL] [COLOR= #DD0000]templates/Default/footer.php[/COLOR][COLOR= #007700];[/COLOR]
?>


Alvast bedankt!
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
waar is je session_start();?
0
Epichotel

Lid · Topicstarter

Berichten
69
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
waar is je session_start();?
Stond nog niet in top.php, was ik vergeten... emoBedankt Aar! biggrin
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