Kan niet meer dan 1 beheerd inlogge

Gestart doorAdmir13 reacties38 weergaven

14 berichten · pagina 1 van 1

Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een script, maar het is vaag. bij het installeren heb ik een admin aangemaakt en die werkt wel. En via admin paneel wil 1tje toevoegen. Dit is het script om inteloggen :

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]../config.php[/COLOR][COLOR= #007700]);[/COLOR]
?>
<html>
<head>
<link rel="stylesheet" href="../style.css" type="text/css" />
<title>Beheerpagina - Inloggen</title>
</head>
<body>
[COLOR= #0000BB]<?php[/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= #FF8000]//Als er op Inloggen is geklikt[/COLOR]
[COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]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= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]]);[/COLOR]
    
    [COLOR= #FF8000]//Check of de gebruikersnaam bestaat[/COLOR]
    [COLOR= #0000BB]$gebruikersnaam_check[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
    
        SELECT
            gebruikersnaam
        FROM
            beheerders
        WHERE 
            gebruikersnaam = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
        LIMIT 2
    
    "[/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]$gebruikersnaam_check[/COLOR][COLOR= #007700]))[/COLOR] [COLOR= #FF8000]//Als de gebruikersnaam niet bestaat[/COLOR]
    [COLOR= #007700]{[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Deze gebruikersnaam komt niet voor in onze database.<br />
        <a href="inloggen.php">Klik hier om terug te gaan</a>."[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #FF8000]//Als de gebruikersnaam we bestaat[/COLOR]
    [COLOR= #007700]{[/COLOR]
        
        [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/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]wachtwoord[/COLOR][COLOR= #007700]]);[/COLOR]
        [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]);[/COLOR]
        
        [COLOR= #FF8000]//Check of de gebruikersnaam en het wachtwoord met elkaar overeenkomen in de database[/COLOR]
        [COLOR= #0000BB]$wachtwoord_check[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
        
            SELECT
                id,
                                gebruikersnaam,
                                wachtwoord
            FROM
                beheerders
            WHERE 
                gebruikersnaam = "[/COLOR][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/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"
            LIMIT 2
        
        "[/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]$gebruikersnaam_check[/COLOR][COLOR= #007700]))[/COLOR] [COLOR= #FF8000]//Als de gebruikersnaam en het wachtwoord niet overeenkomen[/COLOR]
        [COLOR= #007700]{[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"De gebruikersnaam en het wachtwoord komen niet overeen met elkaar.<br />
            <a href="inloggen.php">Klik hier om terug te gaan</a>."[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL] [COLOR= #FF8000]//Als de gebruikersnaam en het wachtwoord wel overeenkomen[/COLOR]
        [COLOR= #007700]{[/COLOR]
            
            [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$beheerder[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$wachtwoord_check[/COLOR][COLOR= #007700]))
            {[/COLOR]
                [COLOR= #FF8000]//Sessions aanmaken[/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= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]);[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$beheerder[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
                
                [COLOR= #FF8000]//Welkom en doorsturen[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<head><meta http-equiv="refresh" content="2; url=index.php"></head>
                
                Welkom "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", je bent succesvol ingelogd.<br />
                <a href="index.php">Klik hier als je niet wordt doorgestuurd naar de beheerpagina</a>.<br />"[/COLOR][COLOR= #007700];
        
            }
            
        }
        
    }[/COLOR]
    
    [URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR] [COLOR= #FF8000]//De databaseconnectie verbreken[/COLOR]
    
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #FF8000]//Als er nog niet op Inloggen is geklikt[/COLOR]
[COLOR= #007700]{[/COLOR]
    [COLOR= #FF8000]//Het formulier[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h2>Inloggen</h2>
    <form method="post" action="inloggen.php">
        <table>
            <tr>
                <td width="100" align="right">
                    Gebruikersnaam:
                </td>
                <td align="left">
                    <input type="text" name="gebruikersnaam" size="30" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    Wachtwoord:
                </td>
                <td align="left">
                    <input type="password" name="wachtwoord" size="30" />
                </td>
            </tr>
        </table>
        <input type="submit" name="login" value="Inloggen" />
    </form>"[/COLOR][COLOR= #007700];
    
}[/COLOR]
?>
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
waarom dat LIMIT 2 ?
je wilt dat hij maximaal 2 rijen uit de db moet halen,
maar ik verwacht dat er maar 1 met die gebruikersnaam is..
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd schreef:
waarom dat LIMIT 2 ?
je wilt dat hij maximaal 2 rijen uit de db moet halen,
maar ik verwacht dat er maar 1 met die gebruikersnaam is..

met 1 wil het ook niet.
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
iemand?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Admir schreef:
Ik heb een script, maar het is vaag.
Je topic ook, wat is je vraag dan?
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Eerdere citaten tonen
Admir schreef:
Ik heb een script, maar het is vaag.
Je topic ook, wat is je vraag dan?
Dat ik niet met een andere gebruikersnaam kan inloggen. Alleen met adi.
Maar ik heb via admin paneel een account voor me vriend gemaakt dat ging goed. Alleen als die wil inloggen komt die niet verder bij inloggen.php en daar zien we alleen een wit scherm
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Wat staat er precies in de broncode dan?
Als je een hele lege pagina krijgt doe je in config.php al wat fout lijkt me.

Ik snap sowieso die LIMIT 2 en die while lus niet.
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Wat staat er precies in de broncode dan?
Als je een hele lege pagina krijgt doe je in config.php al wat fout lijkt me.

Ik snap sowieso die LIMIT 2 en die while lus niet.

met config.php is niks aan de hand, ik include hem in elke script daar en werkt prima. Maar hij kan alleen maar 1 beheerder laten inloggen. als ik uitlog met beheerde account. En ik log met een andere in met de juiste gegevens is die nog steeds wit ik heb LIMIT weer 1 gedaan.

[COLOR= #0000BB]<?php
$host[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR]  

[COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"fokupbzt_sp"[/COLOR][COLOR= #007700];[/COLOR] 

[COLOR= #0000BB]$pass[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"JADITISMEPASSNIETHOORXD"[/COLOR][COLOR= #007700];[/COLOR] 

[COLOR= #0000BB]$db[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"fokupbzt_sp"[/COLOR][COLOR= #007700];[/COLOR]  


[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$user[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$pass[/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/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db[/COLOR][COLOR= #007700]);[/COLOR]

?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Wat staat er precies in de broncode dan?
htmlbroncode dus
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Eerdere citaten tonen
Lennard schreef:
Wat staat er precies in de broncode dan?
htmlbroncode dus
<html>
<head>
<link rel="stylesheet" href="../style.css" type="text/css" />
<title>Beheerpagina - Inloggen</title>
</head>
<body>

emo
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Op regel 27 heb je geen md5() om het wachtwoord heen, op 57 wel?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Zoek dan eens uit hoe die queries eruit zien als ze worden uitgevoerd, ik denk dat je gewoon daar wat fout hebt.

Bovendien:
if(!mysql_num_rows($gebruikersnaam_check))
Hij geeft alleen FALSE terug als het niet gelukt is, niet bij 0 rijen.
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Zoek dan eens uit hoe die queries eruit zien als ze worden uitgevoerd, ik denk dat je gewoon daar wat fout hebt.
Bovendien:
if(!mysql_num_rows($gebruikersnaam_check))
Hij geeft alleen FALSE terug als het niet gelukt is, niet bij 0 rijen.

hij doet vaag ik heb
if(!mysql_num_rows($gebruikersnaam_check) >=1 ) gedaan ipv van if(!mysql_num_rows($gebruikersnaam_check))
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Weet je wel wat t allemaal doet dan?
Je kunt wel lukraak dingen gaan aanpassen in de hoop dat het dan wel werkt, maar als je niet weet wat het doet dan zit er zo weer een andere bug in.
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