Inlog fout..

Gestart doorErik48 reacties269 weergaven

49 berichten · pagina 1 van 4

Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,
Ik ben bezig met Eriks Ledensysteem maar nu heb ik een probleem bij het inloggen.
Ik vul de goede gegevens in maar hij zegt dat ze fout zijn...

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Top includen.[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"top.php"[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                <h1>
                    Login
                </h1>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]//Deze gebruiker is al ingelogd.[/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]id[/COLOR][COLOR= #007700]]))
{[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Hallo,<br />
                Je bent al ingelogd. Om nog een keer in te loggen heeft geen nut.<br />
                <a href="index.html">Home</a>[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #FF8000]//Deze gebruiker is uitgelogd.[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #FF8000]//Deze gebruiker heeft op Login geklikt.[/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]submit[/COLOR][COLOR= #007700]]))
    {[/COLOR]
        [COLOR= #FF8000]//De waardes in een variable zetten.[/COLOR]
        [COLOR= #0000BB]$gebruikersnaam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$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= #FF8000]//Deze gebruiker heeft iets niet ingevuld.[/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]$gebruikersnaam[/COLOR][COLOR= #007700]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700]))
        {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Hallo,<br />
                Je hebt iets niet ingevuld.<br />
                <a href="javascript:history.back(-1)">Verbeter de fout(en)</a>[/COLOR][COLOR= #007700];
        }[/COLOR]
        [COLOR= #FF8000]//Deze gebruiker heeft alles ingevuld.[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [COLOR= #FF8000]//We gaan controleren of deze gegevens in onze database staan.[/COLOR]
            [COLOR= #0000BB]$check[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                            SELECT *
                                FROM users
                            WHERE
                                gebruikersnaam = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$gebruikersnaam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"
                            AND
                                wachtwoord = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"
                                "[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR]echo_mysql_error[COLOR= #007700]());[/COLOR]
            [COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$check[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #FF8000]//Deze gebruiker heeft zijn gegevens fout.[/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]$check[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
            {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Hallo,<br />
                De gegevens die je in vulde kloppen niet met wat er in onze database staat.<br />
                <a href="javascript:history.back(-1)">Verbeter de fout(en)</a>[/COLOR][COLOR= #007700];
            }[/COLOR]
            [COLOR= #FF8000]//Deze gebruiker heeft zijn gegevens goed.[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                [COLOR= #FF8000]//We gaan zijn sessions aan maken.[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]last_login[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]last_login[/COLOR][COLOR= #007700]];[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]];[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]];[/COLOR]
                [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]munten[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]munten[/COLOR][COLOR= #007700]];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                Hallo,<br />
                Je bent succesvol ingelogd.<br />
                <a href="index.html">Home</a>[/COLOR][COLOR= #007700];
            }
        }
    }[/COLOR]
    [COLOR= #FF8000]//Deze gebruiker heeft nog niet op Login geklikt.[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
                <form action="" method="post">
                    <table width="100%">
                        <tr>
                            <td class="een">
                                Gebruikersnaam
                            </td>
                            <td class="een">
                                <input type="text" name="gebruikersnaam" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Wachtwoord
                            </td>
                            <td>
                                <input type="password" name="wachtwoord" />
                            </td>
                        </tr>
                        <tr>
                            <td class="een">
                            </td>
                            <td class="een">
                                <input type="submit" name="submit" value="Login" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <a href="registreer.html">Registreer</a>
                            </td>
                        </tr>
                    </table>
                </form>[/COLOR][COLOR= #007700];
    }
}[/COLOR]
[COLOR= #FF8000]//Bottom includen.[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"bottom.php"[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
".$gebruikersnaam." moet dat niet $gebruikersnaam zijn?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Nee, dat is juist goed zo.

Ga eens kijken welke waardes $gebruikersnaam en $wachtwoord hebben en welke jij verwacht dat ze hebben.
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je doet btw een empty check na een md5(), niet echt handig want een lege string wordt ook een 32 chars lange string in md5 emo
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oowja
sorry ben echt slecht in fouten ontdekken, maar oefenen oefenen en oefenen
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Bovendien moet je geen empty() gebruiken, maar isset() en trim($var) == , en ik zou $gebruikersnaam door mysql_real_escape_string() halen, is effe wat veiliger..
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het werkt niet.. Als ik foute gegevens invul zegt hij dat ze goed zijn... Weet iemand de fout?
PS. Ik krijg deze fout:
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Zoek eens uit welke waardes $gebruikersnaam en $wachtwoord hebben en welke je verwacht dat ze hebben..
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Huh?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Als je bij die query $gebruikersnaam en $wachtwoord echot, welke waardes hebben ze dan?
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En hoe echo je die?
Gewoon
?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Verander dit:

$check = mysql_query("
                            SELECT *
                                FROM users
                            WHERE
                                gebruikersnaam = ".$gebruikersnaam."
                            AND
                                wachtwoord = ".$wachtwoord."
                                ") or die(echo_mysql_error());


eens door dit:

$check = mysql_query(($q = "
                            SELECT *
                                FROM users
                            WHERE
                                gebruikersnaam = ".$gebruikersnaam."
                            AND
                                wachtwoord = ".$wachtwoord."
                                ")) or die(echo_mysql_error());
            echo $q;


en dan die output hier neerzetten (zorg er wel voor dat je wachtwoord er niet puur in staat).
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
SELECT * FROM users WHERE gebruikersnaam = Erik AND wachtwoord = jjjjj Hallo,
Je bent succesvol ingelogd.
Home
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Verander dit:
if(mysql_num_rows($check) < 0)
ook nog in dit:
if(mysql_num_rows($check) !== 1)
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu zegt ie dat alles fout... Terwijl die gewoon goed zijn
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