session inloggen, naar profiel gaan, terug , session kwijt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php session_start (); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
....
<?php
include 'mysql.php';
//query's from database
$searchemail = mysql_query("SELECT * FROM members WHERE email = '".$_POST["email"]."'");
$passwordmd5 = md5($_POST['password']);
$emailandpassword = mysql_query("SELECT * FROM members WHERE email = '".$_POST['email']."' AND password = '$passwordmd5'");
$queryparagraph = "SELECT id, title, paragraph FROM paragraphs WHERE id=2";
if ($_POST["sendbutton"] != "Inloggen" || !(mysql_num_rows($emailandpassword) == 1) )
{
echo "<div id=\"container\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=dagboek\">Dagboek</a></li>\n";
echo "<li><a href=\"index.php?p=film\">Films</a></li>\n";
echo "<li><a href=\"index.php?p=bubbles\">Spelen</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=gastenboek&page=0\">Gastenboek</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\"><a href=\"index.php?p=register\">[Register]</a> </div>\n";
echo "<div id=\"content\">\n";
// ask for queryparagraph
$resultparagraph = mysql_query($queryparagraph);
$rowparagraph = mysql_fetch_array($resultparagraph);
// title and paragraph from database
echo "<h1>".$rowparagraph["title"]."</h1>\n";
echo "<div align=\"center\">\n";
echo "<p>\n";
echo $rowparagraph ["paragraph"];
echo "</p>\n";
?>
<form id="formlogin" name="formlogin" method="post" action="index.php?p=login">
<table>
<tr>
<th>Gebruikersnaam (Email):</th>
<td><input name="email" type="text" id="email" size="37" value="<?php echo $_POST["email"] ?>"/></td>
</tr>
<?php
if ($_POST["sendbutton"] && mysql_num_rows($searchemail) == 0)
{
echo "<tr>\n";
echo "<td> </td>\n";
echo "<td class=\"remark\">Dit email adres bestaat niet!</td>\n";
echo "</tr>\n";
}
?>
<tr>
<th>Wachtwoord:</th>
<td><input name="password" type="password" id="password" size="37" value="<?php echo $_POST["password"] ?>"/></td>
</tr>
<tr>
<td></td>
<th><a href="index.php?p=forgot">wachtwoord vergeten</a> <input name="sendbutton" type="submit" id="inloggen" value="Inloggen" /></th>
</tr>
</table>
</form>
<?php
}
else
{
$status= mysql_fetch_assoc ($emailandpassword);
$emailandpassword = mysql_fetch_array($emailandpassword);
if ($status['status'] == "n")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom gebruiker: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "n";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Welkom !</h3>";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
}
elseif ($status['status'] == "m")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom moderator: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "m";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Welkom</h3>";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
}
elseif ($status['status'] == "a")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "<li><a href=\"index.php?p=admin\">Admin</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom administrator: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "a";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Beheerdersoverzicht</h3>";
echo "<ul id=\"navlistvert\">\n";
echo "<li><a href=\"admin/index.php?p=users\">Gebruikers beheer</a></li>\n";
echo "<li><a href=\"admin/index.php?p=groups\">Groeps beheer</a></li>\n";
echo "<li>Dagboek beheer</li>\n";
echo "<li>Forum beheer</li>\n";
echo "</ul>\n";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
?>
<?php
}
else
{
echo "Gebruikersnaam en/of wachtwoord verkeerd<br><br/>";
}
}
?>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
....
<?php
include 'mysql.php';
//query's from database
$searchemail = mysql_query("SELECT * FROM members WHERE email = '".$_POST["email"]."'");
$passwordmd5 = md5($_POST['password']);
$emailandpassword = mysql_query("SELECT * FROM members WHERE email = '".$_POST['email']."' AND password = '$passwordmd5'");
$queryparagraph = "SELECT id, title, paragraph FROM paragraphs WHERE id=2";
if ($_POST["sendbutton"] != "Inloggen" || !(mysql_num_rows($emailandpassword) == 1) )
{
echo "<div id=\"container\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=dagboek\">Dagboek</a></li>\n";
echo "<li><a href=\"index.php?p=film\">Films</a></li>\n";
echo "<li><a href=\"index.php?p=bubbles\">Spelen</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=gastenboek&page=0\">Gastenboek</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\"><a href=\"index.php?p=register\">[Register]</a> </div>\n";
echo "<div id=\"content\">\n";
// ask for queryparagraph
$resultparagraph = mysql_query($queryparagraph);
$rowparagraph = mysql_fetch_array($resultparagraph);
// title and paragraph from database
echo "<h1>".$rowparagraph["title"]."</h1>\n";
echo "<div align=\"center\">\n";
echo "<p>\n";
echo $rowparagraph ["paragraph"];
echo "</p>\n";
?>
<form id="formlogin" name="formlogin" method="post" action="index.php?p=login">
<table>
<tr>
<th>Gebruikersnaam (Email):</th>
<td><input name="email" type="text" id="email" size="37" value="<?php echo $_POST["email"] ?>"/></td>
</tr>
<?php
if ($_POST["sendbutton"] && mysql_num_rows($searchemail) == 0)
{
echo "<tr>\n";
echo "<td> </td>\n";
echo "<td class=\"remark\">Dit email adres bestaat niet!</td>\n";
echo "</tr>\n";
}
?>
<tr>
<th>Wachtwoord:</th>
<td><input name="password" type="password" id="password" size="37" value="<?php echo $_POST["password"] ?>"/></td>
</tr>
<tr>
<td></td>
<th><a href="index.php?p=forgot">wachtwoord vergeten</a> <input name="sendbutton" type="submit" id="inloggen" value="Inloggen" /></th>
</tr>
</table>
</form>
<?php
}
else
{
$status= mysql_fetch_assoc ($emailandpassword);
$emailandpassword = mysql_fetch_array($emailandpassword);
if ($status['status'] == "n")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom gebruiker: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "n";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Welkom !</h3>";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
}
elseif ($status['status'] == "m")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom moderator: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "m";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Welkom</h3>";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
}
elseif ($status['status'] == "a")
{
echo "<div id=\"container2\">\n";
echo "<ul id=\"navlist\">\n";
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "<li><a href=\"index.php?p=admin\">Admin</a></li>\n";
echo "</ul>\n";
echo "<div id=\"login\">\n";
echo "Welkom administrator: \n";
$sql = "SELECT * from members where id='".$_SESSION['id']."'";
$resultaat = mysql_query($sql) or die ("Er is iets mis met het vertonen van de members");
$rij = mysql_fetch_array($resultaat);
echo "<br/><strong>".$rij ["nickname"]."</strong> ";
echo "<a href=\"index.php?p=logout\">[Uitloggen]</a> </div>\n";
echo "<div id=\"content\">\n";
$_SESSION['sendbutton'] = "1";
$_SESSION['status'] = "a";
$_SESSION['email'] = $email;
$_SESSION['id'] = $status ['id'];
echo "<h3>Beheerdersoverzicht</h3>";
echo "<ul id=\"navlistvert\">\n";
echo "<li><a href=\"admin/index.php?p=users\">Gebruikers beheer</a></li>\n";
echo "<li><a href=\"admin/index.php?p=groups\">Groeps beheer</a></li>\n";
echo "<li>Dagboek beheer</li>\n";
echo "<li>Forum beheer</li>\n";
echo "</ul>\n";
echo "<div class=\"remark\">Deze pagina is nog in opmaak, dus nog even geduld !</div><br/>\n";
?>
<?php
}
else
{
echo "Gebruikersnaam en/of wachtwoord verkeerd<br><br/>";
}
}
?>
</div>
</div>
</div>
</body>
</html>
als ik inlog, krijg ik zoals hierboven
Code (php)
1
2
3
4
5
2
3
4
5
echo "<li><a href=\"index.php?p=login\" id=\"actief\">Home</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "<li><a href=\"index.php?p=admin\">Admin</a></li>\n";
echo "<li><a href=\"index.php?p=profile\">Profile</a></li>\n";
echo "<li><a href=\"index.php?p=forum\">Forum</a></li>\n";
echo "<li><a href=\"index.php?p=pages\">Pages</a></li>\n";
echo "<li><a href=\"index.php?p=admin\">Admin</a></li>\n";
te zien. als ik nu op de link home druk, (terug naar de login) dan zou ik hetzelfde moeten zien, wel hier loopt het ergens fout, hij laat opeens de login zien, iemand een idee wat dit kan zijn ?
Gewijzigd op 01/01/1970 01:00:00 door Steven Cuypers
zoiets als dit:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
session_start();
// bekijk of de gene al is ingelogd
if ($_SESSION["ingelogd"] && !$loguit)
{
//echo "hier komt de pagina als je ingelogd bent";
}
else {
header("Location: login.php");
}
?>
session_start();
// bekijk of de gene al is ingelogd
if ($_SESSION["ingelogd"] && !$loguit)
{
//echo "hier komt de pagina als je ingelogd bent";
}
else {
header("Location: login.php");
}
?>
nimtex schreef op 29.06.2008 16:14:
Je moet ervoor zorgen dat als je naar een andere pagina gaat dat hij de sessie onthoud. dit kan doormiddel van een check.php te maken en die op elke pagina te includen.
zoiets als dit:
zoiets als dit:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
session_start();
// bekijk of de gene al is ingelogd
if ($_SESSION["ingelogd"] && !$loguit)
{
//echo "hier komt de pagina als je ingelogd bent";
}
else {
header("Location: login.php");
}
?>
session_start();
// bekijk of de gene al is ingelogd
if ($_SESSION["ingelogd"] && !$loguit)
{
//echo "hier komt de pagina als je ingelogd bent";
}
else {
header("Location: login.php");
}
?>
mercikes voor de info. Het is nu in orde geraakt door uw advies !