[PHP] Hulp gevraagd!

Gestart doorJosnl31 reacties37 weergaven

32 berichten · pagina 3 van 3

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Toch een probleempje, en wel bij het gedeelte met de sessie, en het weergeven van de voornaam:

Dit is de code van de beveiligde pagina:

[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/ob_start"]ob_start[/URL][COLOR= #007700]();[/COLOR] 
[URL="http://www.php.net/session_start"]session_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>Beheerpaneel</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]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT voornaam FROM leden WHERE voornaam = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ingelogd[/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/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ingelogd, "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]])){[/COLOR]
    
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je kunt dit gedeelte niet zien omdat je niet bent ingelogd. Je kunt <a href="inloggen.php">hier</a> inloggen.[/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]Welkom terug [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700];
}[/COLOR]


?>

</body>
</html>


Alleen weergeeft ie de naam van de gebruiker niet.
Het heeft met deze regels te maken, dat weet ik wel, alleen weet ik nu niet hoe ik de voornaam kan weergeven:

$query = mysql_query("SELECT voornaam FROM leden WHERE voornaam = " . mysql_real_escape_string($_SESSION[ingelogd]) . "");


Zou iemand trouwens kunnen checken of ik zo de sessie goed gebruik?

Op deze pagina wordt de sessie aangemaakt:

[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>

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

[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]$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]pass[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]ehgi/,,.[]!@*!#()qstzjq07!#%^^(!)[/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][URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$salt[/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= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ingelogd, "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]];[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je bent succesvol ingelogd![/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: admin.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]De ingevulde gegevens zijn niet correct, probeer het nog eens![/COLOR][COLOR= #007700];
    
}[/COLOR]

?>

</body>
</html>


Alvast bedankt voor de hulp allemaal!thumbsup
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Session aanmaken: (inlog pagina)

$_SESSION[ingelogd] = $_POST[naam];


Naam weergeven

$_SESSION[ingelogd];


Kijken of je wel ingelogd bent:

if(!isset($_SESSION[ingelogd])){
echo"Niet ingelogd";
}else{
echo"Hallo ".$_SESSION[ingelogd]."";
}


,Jesse
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