Hallo allemaal!
Ik ben bezig met een script, alleen kom ik niet verder bij het logingedeelte.
Dit is mijn code:
Dit snap ik allemaal wel (anders had ik het ook niet gemaakt
) alleen weet ik niet hoe je kan kijken of de ingevulde gebruikersnaam overeenkomt met het ingevulde wachtwoord.
Erik vertelde me iets over fetchen, alleen snap ik dat niet helemaal.
Ik hoop dat jullie me kunnen helpen,
Gr.
Jos
Ik ben bezig met een script, alleen kom ik niet verder bij het logingedeelte.
Dit is mijn code:
[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= #0000BB]$gebrnaam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #FF8000]//Database gegevens ophalen[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebrnaam,wachtwoord 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]$gebrnaam[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]//Kijken of de ingevulde gebruikersnaam hoort bij het ingevulde wachtwoord[/COLOR]
HIER KOM IK NIET VERDER [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]<font color="#009900">Je bent succesvol ingelogd!</font>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: succes.php[/COLOR][COLOR= #007700]);
}[/COLOR]
[COLOR= #FF8000]//Als de gegevens niet kloppen echoen: De ingevulde gegevens zijn niet correct [/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$gebruiker[/COLOR] [COLOR= #007700]!==[/COLOR] [COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<font color="#FF0000">De ingevulde gegevens zijn niet correct.</font>[/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> Dit snap ik allemaal wel (anders had ik het ook niet gemaakt
) alleen weet ik niet hoe je kan kijken of de ingevulde gebruikersnaam overeenkomt met het ingevulde wachtwoord.Erik vertelde me iets over fetchen, alleen snap ik dat niet helemaal.
Ik hoop dat jullie me kunnen helpen,
Gr.
Jos





