login

Gestart doorFreestyle18 reacties34 weergaven

19 berichten · pagina 2 van 2

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/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]login[/COLOR][COLOR= #007700]])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U bent al ingelogd!"[/COLOR][COLOR= #007700];
}[/COLOR]


zoiets?
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je kijkt of het wachtwoord matcht met de gebruikersnaam, en je gebruikt mysql_num_rows();, dan kan je kijken of het resultaat 1 is.

Dus als mysql_num_rows(); gelijk aan 1 is, dan zet je in de if zoiets neer:

[COLOR= #0000BB]<?php[/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= #DD0000]$query[/COLOR][COLOR= #007700])){[/COLOR]

      [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$userid[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//opgehaald via een query[/COLOR]
      [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$username[/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 ingevoerde gegevens zijn onjuist.[/COLOR][COLOR= #007700];

}[/COLOR]

?>
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
wat heeft het user id met het inloggen te maken??
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Die sessies worden aangemaakt als je inlogt, zo kan je kijken op andere paginas of iemand wel is ingelogd, dit doe je bijv zo:

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

[COLOR= #FF8000]//$userid en $username kan je ophalen met een query :)[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_id[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$userid[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700]){[/COLOR]

    [COLOR= #FF8000]//code van je pagina, er is namelijk ingelogd.[/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]Om deze pagina te bekijken dien je ingelogd te zijn.[/COLOR][COLOR= #007700];

}[/COLOR]

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