inloggen

Gestart doorLars11 reacties115 weergaven

12 berichten · pagina 1 van 1

Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik kom weer is ergens niet uit.

Als ik inlog kan ik met ieder willekeurig wachtwoord inloggen.
Wie ziet het probleem ?

[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
?>
[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] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]]))
{[/COLOR]

    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE 
            naam 
                = 
                    $_POST[user] 
                AND 
            wachtwoord 
                = 
                    "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]$_POST[pass][/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]$query[/COLOR][COLOR= #007700]) !==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
    {[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Incorrecte login![/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<meta http-equiv="refresh" content="1;URL=inloggen.php" />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        
        [COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]memberid[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<meta http-equiv="refresh" content="0;URL=index.php" />[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br /><br />Welkom, je bent ingelogd.[/COLOR][COLOR= #007700];
    
    }
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    
    ?>
    <form name="form1" id="form1" method="post" action="">
        <p>
            Gebruikersnaam:<br />
            <input name="user" type="text" id="user" /><br />
            Wachtwoord:<br />
            <input name="pass" type="password" id="pass" /><br />
            <input type="submit" name="Submit" value="Inloggen" />
        </p>
    </form>
    [COLOR= #0000BB]<?php[/COLOR]

[COLOR= #007700]}[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Variabelen buiten quotes..
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waar precies die variable buiten de quote?
0
Berichten
166
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
verander

$query = mysql_query("SELECT * FROM leden WHERE
            naam
                =
                    $_POST[user]
                AND
            wachtwoord
                =
                    ".md5($_POST[pass])."
                ");


in

$query = mysql_query("SELECT * FROM leden WHERE
            naam
                =
                    ".$_POST[user]."
                AND
            wachtwoord
                =
                    ".md5($_POST[pass])."
                ");


dan zou het moeten werken denk ik
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu krijg ik bij alles incorrecte log-in
0
Berichten
166
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$query = mysql_query("SELECT * FROM leden WHERE
            naam
                =
                    ".$_POST[user]."
                AND
            wachtwoord
                =
                    ".md5($_POST[pass])."
                ");


Nu? anders weet ik het ni...
0
Berichten
37
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
weet niet of je er iets aan hebt maar dit is mijn sql:

$sql= "SELECT password FROM members WHERE username=".$username = $_POST[username]."";


Misschien dat je hier iets aan hebt..

en even verderop kijk ik op het password klopt dmv:

if ($row[password] == md5($_POST[password])){
    echo ingelogt;
} else {
    echo Foutieve gebruikersnaam en/of wachtwoord.;
}
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke na wachtwoord opvragen werkt hij wel.

Maar nu kom ik er net achter dat hij telkens dezelfde md5 doorgeeft bij het aanmelden

Wie ziet de fout ?

[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
?>        
          [COLOR= #0000BB]<?[/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]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Geen username ingevuld!"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Geen wachtwoord ingevuld!"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass2[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Geen herhalend wachtwoord ingevuld!"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Geen emailadres ingevuld!"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass[/COLOR][COLOR= #007700]]!=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pass2[/COLOR][COLOR= #007700]]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De twee wachtwoorden zijn niet hetzelfde.[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er bevinden zich rare tekens in de naam.()"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]">"[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er bevinden zich rare tekens in de naam.(>)"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]"<"[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er bevinden zich rare tekens in de naam.(<)"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]"´"[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er bevinden zich rare tekens in de naam.(´)"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]"/"[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er bevinden zich rare tekens in de naam.(/)"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er mogen geen spaties in de gebruikersnaam."[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je gebruikersnaam mag niet meer dan 20 tekens hebben."[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])){[/COLOR] 
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Is je email wel goed ingevuld?"[/COLOR][COLOR= #007700]; 
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"select * from leden where naam=$_POST[user]"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_Array"]mysql_fetch_Array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Gebruikersnaam is in gebruik, kies een andere!"[/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]"INSERT INTO leden (
        naam, 
        wachtwoord, 
        email, 
        ip, 
        tijd, 
        rang
            ) VALUES (
                $_POST[user],
                "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]$_POST[pass][/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]", 
                $_POST[email],
                "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", 
                "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y:d:m:H:i:s"[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]", 
                Lid
            )"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/print"]print[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Je hebt je succesvol aangemeld.<br>Je kan nu inloggen!"[/COLOR][COLOR= #007700];
}}}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
    </p>
    <form name="form1" method="post" action="">
          <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
  Gebruikersnaam:<br>
  <input name="user" type="text" id="user">
  <br>
  Wachtwoord:<br>
  <input name="pass" type="password" id="pass">
  <br>
  Herhaal wachtwoord:<br>
  <input name="pass2" type="password" id="pass2">
  <br>
  Emailadres:<br>
  <input name="email" type="text" id="email">
  <br>
  <input type="submit" name="Submit" value="Aanmelden">
  </font> 
</form>
        [COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
md5($_POST[pass]) moet buiten quotes, dus: md5($_POST[pass])
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Mijn baggere scripting yummieMaarja, ik had deze fout ookal ontdekt en wou het op msn tegen je zeggen, maar je was niet online. yummie Maarja nu is het ook opgelost
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Daarom moet je ook variabelen buiten quotes doen, dan zal dit soort dingen je nooit overkomen. clown
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar het vaagste is dat het wel op mijn site werkt..

http://makecity.nl/rap
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