[PHP] Hulp gevraagd!

Gestart doorJosnl31 reacties37 weergaven

32 berichten · pagina 2 van 3

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja oké, maar die query heb ik al.yummie
Alvast bedankt, ik ga even kijken of ik het werkend kan krijgen!biggrin
EDIT:

Ik heb nu deze code, maar dit werkt helaas niet. Alles is dubbelgechecked...

[COLOR= #0000BB]<?php[/COLOR]     
        [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
        [URL="http://www.php.net/ob_start"]ob_start[/URL][COLOR= #007700]();[/COLOR]
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inloggen</title>
</head>

<body>


[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]//Kijken of de ingevulde gebruikersnaam hoort bij het ingevulde wachtwoord[/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 gebrnaam = "[/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]" 
AND 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]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]
    
[COLOR= #FF8000]//Als het klopt: cookie aanmaken, en weergeven dat je succesvol bent ingelogd    [/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"ingelogd"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]],[/COLOR] [URL="http://www.php.net/Time"]Time[/URL][COLOR= #007700]()+[/COLOR][COLOR= #0000BB]3600[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]24[/COLOR][COLOR= #007700]*[/COLOR][COLOR= #0000BB]7[/COLOR][COLOR= #007700]);[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Succes[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: succes.php[/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]Failed[/COLOR][COLOR= #007700];
    
}[/COLOR]

?>


<form action="" method="post">
   <table border="0">
      <tr>
         <td><input type="text" name="naam" value="Gebruikersnaam" size="20px"></td>
      </tr>
      <tr>
         <td><input type="password" name="pass" value="Wachtwoord" size="20px"></td>
      </tr>
      <tr>
         <td><input type="submit" name="inloggen" value="Inloggen"></td>
      </tr>
   </table>
</form>

</body>
</html>


Alvast bedankt.
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Iemand die me kan helpen?bloos
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
K heb geen idee sorry
Misschien wat ik via msn stuurde eens proberen?
0
Miel

Lid

Berichten
4.462
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wachtwoord door de hash halen?xdsetcookie("ingelogd", $_POST[naam], Time()+3600*24*7);
Is zo niet veilig trouwens.. Cookies kan je veranderen.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Idd je kan beter met sessions werken wink
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En sessions kan je uitwisselen, als je een betere manier hebt hoor ik het natuurlijk graag!

En hoe kan ik het wachtwoord door de hash halen?bloos
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Cookies en Sessies gebruiken smile
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
$wachtwoord = hash(sha512, $_POST[wachtwoord]);

zo?
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nieuw probleem, krijg deze error:

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/onehosted/domains/onehosted.nl/public_html/klanten/CMS/inloggen.php on line 23


Dit is regel 22-23:

[COLOR= #0000BB]<?php


$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE gebrnaam = "[/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]" 
AND wachtwoord = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]sha512[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]

?>
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php


$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE gebrnaam = "[/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]" 
AND wachtwoord = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR]hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]"sha512"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$wachtwoord[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$salt[/COLOR][COLOR= #007700])).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]

?>
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar wat is $salt dan?bloos
EDIT:

Heb mn $salt al.winkAlleen werkt het nog nietcry
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
thumbsup
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
¨code*
$wachtwoord = hash(sha512, $_POST[pass]);
$query = mysql_query("SELECT * FROM leden WHERE gebrnaam = " . mysql_real_escape_string($_POST[naam]) . "
AND wachtwoord = ".mysql_real_escape_string($wachtwoord)."");

?>
[/code]
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het werkt ondertussen al, sorry dat ik dit niet eerder heb vermeld, bedankt allemaal!
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Das mooithumbsup
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