Login

Gestart doorShahiem3 reacties46 weergaven

4 berichten · pagina 1 van 1

Shahiem

Lid · Topicstarter

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

Ik heb een login script maar als je wordt ingelogd komt er een groene div maar daar onder ook een div van error terwijl die er niet moet staan.

Hoe los ik dat op?

define("Titel","Inloggen");
include includes/config.php; 
include includes/header.php; 

    if(!isset($_SESSION[login]))
                {
                
if(isset($_POST[inloggen]))
{
    if(empty($_POST[naam]) || empty($_POST[pass]))
    {
        echo <div class="error">Je hebt niet alle velden ingevuld!</div>;
    }
    else
    {
        $sql = mysql_query("SELECT * FROM leden WHERE naam = ".mysql_real_escape_string($_POST[naam])."");
        if(mysql_num_rows($sql) != 1){
            $string = Deze gebruiker bestaat niet!;
        }
        else
        {
            $sql = mysql_fetch_assoc($sql);
            
            if($sql[pass] != md5($_POST[pass]))
            {
                $string = Het wachtwoord was incorrect!;
            }
            else{
                if($sql[ban] == 1)
                {
                    $string = Je bent verbannen!;
                }
                else
                {
                
                    $_SESSION[login] = $sql[ID];
                    echo <div class="gelukt">Je bent succesvol ingelogd.</div>;
                }
            }
        }
            echo <div class="error">.$string.</div>;
        }
}
else
{
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Titel"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"Inloggen"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/config.php[/COLOR][COLOR= #007700];[/COLOR] 
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/header.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]login[/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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]inloggen[/COLOR][COLOR= #007700]]))
{[/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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]]))
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">Je hebt niet alle velden ingevuld!</div>[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE naam = "[/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]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][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]$sql[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
        {[/COLOR]
            [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Deze gebruiker bestaat niet![/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]] !=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]]))
            {[/COLOR]
                [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Het wachtwoord was incorrect![/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][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ban[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
                {[/COLOR]
                    [COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Je bent verbannen![/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
                
                    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ID[/COLOR][COLOR= #007700]];[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="gelukt">Je bent succesvol ingelogd.</div>[/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]$string[/COLOR][COLOR= #007700]))
        {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="error">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
        }
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
?>
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dankjewel Luuk biggrin
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Graag gedaan 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