Hoi, ik ben bezig met een upload site inc. inlog systeem etc.
Dit topic dient ervoor om mij wat te helpen
Aangezien ik niet goed PHP kan zou ik graag dat je het nummer van het probleem er bij zet. (in je reactie) Alvast bedankt
Alle opgeloste problemen komen in een spoiler!
Probleem 1:
Ik wil graag dat als ik inlog met naam komt te staan,
Log in.php:
Pagina als je bent ingelogd:
Ik wil graag dat het er zo uit ziet;
Je bent ingelogd als, admin
Hoe doe ik dat?
Probleem 2:
Log uit werkt niet,
Code:
Werkt niet omdat; als je weer terug gaat naar die pagina staat er nog: Je bent ingelogd.
Dit topic dient ervoor om mij wat te helpen
Aangezien ik niet goed PHP kan zou ik graag dat je het nummer van het probleem er bij zet. (in je reactie) Alvast bedankt
Alle opgeloste problemen komen in een spoiler!Probleem 1:
Ik wil graag dat als ik inlog met naam komt te staan,
Log in.php:
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]menu.php[/COLOR][COLOR= #007700]);[/COLOR] ?>
<html>
<head>
<title>Uploadmania.nl <3 - Upload al jou favorite plaatjes/afbeelding!</title>
<style type="text/css">
Overbodige tekst :")
</style>
</head>
<body>
<div id="boven">
<div id="logo">
<a href="index.php"><marquee><img src="logo.png" alt="logo" /></marquee></a>
</div>
</div>
<div id="midden">
<div id="big">
<div id="menu">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$url[/COLOR] ?></a></div>
<center><br /><br />
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// session_start();[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]mysql.php[/COLOR][COLOR= #007700]);[/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]
[COLOR= #0000BB]$arrErrors[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]))
{[/COLOR]
[COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username = "[/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]username[/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]$sQuery[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$userFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je bent succesvol ingelogd, je word doorgestuurd[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// Doorsturen of session stuff hier[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: ./in/index.php[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$arrErrors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Wachtwoord klopt niet.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$arrErrors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Gebruikersnaam niet gevonden[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$arrErrors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Voer uw gebruikersnaam en wachtwoord in.[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Er [/COLOR] [COLOR= #007700]. ([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$arrErrors[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]?[/COLOR] [COLOR= #DD0000]is 1 fout[/COLOR] [COLOR= #007700]:[/COLOR] [COLOR= #DD0000]zijn [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$arrErrors[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000] fouten[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000] opgetreden:<br />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$arrErrors[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$errId[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$errMelding[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$errMelding[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];
}
}[/COLOR]
?>
<form action=login.php method=POST>
Gebruikersnaam: <input type=text name=username> <br />
Wachtwoord: <input type=password name=wachtwoord><br />
<input type=submit value=Log in!>
</form>
</center>
<br />
<h2>Nog geen account? <a href="">REGISTEER GRATIS!</a>
</div>
<div id="footer">
<center>© - [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y[/COLOR][COLOR= #007700])[/COLOR] ?> by UploadMania.nl, alle rechten voorbehouden</center>
</div>
</div>
</body>
</html> Pagina als je bent ingelogd:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]])[/COLOR]
[COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]Je bent ingelogd als, [/COLOR][COLOR= #007700]);[/COLOR]
?> Ik wil graag dat het er zo uit ziet;
Je bent ingelogd als, admin
Hoe doe ik dat?
Probleem 2:
Log uit werkt niet,
Code:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/session_destroy"]session_destroy[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent uitgelogd"[/COLOR][COLOR= #007700];[/COLOR]
?> Werkt niet omdat; als je weer terug gaat naar die pagina staat er nog: Je bent ingelogd.
