Hulp nodig met sessions!
Fatal error: Can't use function return value in write context in E:\Websites\tmtf_11\website\inlogcheck.php on line 47
Hier is m'n code:
inlogcheck.php
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
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
<?php
if(isset($_REQUEST["Submit"])){
session_start();
connectie info is even weggehaald
$Verbinding = mysql_connect("$host", "$gebruiker_mysql", "$wachtwoord2") or die("<p>De verbinding met de database kan niet worden gemaakt</p>" . mysql_error());
mysql_select_db($DBNaam) or die("<p>De database kan niet geselecteerd worden</p>");
// Define $myusername and $mypassword
$Inlognaam=$_POST["Inlognaam"];
$Wachtwoord=$_POST["Wachtwoord"];
// To protect MySQL injection (more detail about MySQL injection)
$Inlognaam = stripslashes($Inlognaam);
$Wachtwoord = stripslashes($Wachtwoord);
$Inlognaam = mysql_real_escape_string($Inlognaam);
$Wachtwoord = mysql_real_escape_string($Wachtwoord);
$sql="SELECT * FROM $tbl_name WHERE Inlognaam='$Inlognaam' and Wachtwoord='$Wachtwoord'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$Inlognaam = $_REQUEST["Inlognaam"];
$Wachtwoord = $_REQUEST["Wachtwoord"];
$_SESSION("Inlognaam") = $Inlognaam;
$_SESSION("Wachtwoord") = $Wachtwoord;
header("location:ingelogd.php");
}
else {
echo "Wrong Username or Password";
}
}
?>
if(isset($_REQUEST["Submit"])){
session_start();
connectie info is even weggehaald
$Verbinding = mysql_connect("$host", "$gebruiker_mysql", "$wachtwoord2") or die("<p>De verbinding met de database kan niet worden gemaakt</p>" . mysql_error());
mysql_select_db($DBNaam) or die("<p>De database kan niet geselecteerd worden</p>");
// Define $myusername and $mypassword
$Inlognaam=$_POST["Inlognaam"];
$Wachtwoord=$_POST["Wachtwoord"];
// To protect MySQL injection (more detail about MySQL injection)
$Inlognaam = stripslashes($Inlognaam);
$Wachtwoord = stripslashes($Wachtwoord);
$Inlognaam = mysql_real_escape_string($Inlognaam);
$Wachtwoord = mysql_real_escape_string($Wachtwoord);
$sql="SELECT * FROM $tbl_name WHERE Inlognaam='$Inlognaam' and Wachtwoord='$Wachtwoord'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$Inlognaam = $_REQUEST["Inlognaam"];
$Wachtwoord = $_REQUEST["Wachtwoord"];
$_SESSION("Inlognaam") = $Inlognaam;
$_SESSION("Wachtwoord") = $Wachtwoord;
header("location:ingelogd.php");
}
else {
echo "Wrong Username or Password";
}
}
?>
inloggen.php
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
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
<!DOCTYPE HTML>
<html><head><title>TMTF_11</title><meta name="description" content="website description"><meta name="keywords" content="website keywords, website keywords"><meta http-equiv="content-type" content="text/html; charset=windows-1252"><link rel="stylesheet" type="text/css" href="style/style.css"></head><body>
<div id="main">
<div id="header">
<div id="logo">
<div id="logo_text">
<!-- class="logo_colour", allows you to change the colour of the text -->
<h1><a href="index.html">Afa<span class="logo_colour">sie</span></a></h1>
<h2>Leer meer over Afasie.</h2>
</div>
</div>
<div id="menubar">
<ul id="menu"><!-- put class="selected" in the li tag for the selected page - to highlight which page you're on --><li><a href="index.html">Home</a></li>
<li><a href="informatie.html">Informatie</a></li>
<li><a href="oefenen.php">Oefenen</a></li>
<li><a href="scorelijst.php">Scorelijst</a></li>
<li><a href="gebruikerslijst.php">Gebruikerslijst</a></li>
<li><a href="inloggen.php">Inloggen</a></li>
<li><a href="registreren.php">Registreren</a></li>
<li><a href="contact.html">Contact</a></li>
</ul></div>
</div>
<div id="content_header"></div>
<div id="site_content">
<div id="sidebar_container">
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
<!-- insert your sidebar items here -->
</div>
<div class="sidebar_base"></div>
</div>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
</ul></div>
<div class="sidebar_base"></div>
</div>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
</div>
<div class="sidebar_base"></div>
</div>
</div>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="inlogcheck.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Inloggen </strong></td>
</tr>
<tr>
<td width="78">Gebruikersnaam</td>
<td width="6">:</td>
<td width="294"><input name="Inlognaam" type="text" id="Inlognaam"></td>
</tr>
<tr>
<td>Wachtwoord</td>
<td>:</td>
<td><input name="Wachtwoord" type="password" id="Wachtwoord"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</div>
<div id="content_footer"></div>
<div id="footer">
<p><a href="index.html">Home</a> | <a href="informatie.html">Informatie</a> | <a href="oefenen.html">Oefenen</a> | <a href="scorelijst.php">Scorelijst</a> | <a href="gebruikerslijst.php">Gebruikerslijst</a> | <a href="inloggen.php">Inloggen</a> | <a href="registreren.php">Registreren</a> | <a href="contact.html">Contact</a></p>
</p>
</div>
</div>
</body></html>
<html><head><title>TMTF_11</title><meta name="description" content="website description"><meta name="keywords" content="website keywords, website keywords"><meta http-equiv="content-type" content="text/html; charset=windows-1252"><link rel="stylesheet" type="text/css" href="style/style.css"></head><body>
<div id="main">
<div id="header">
<div id="logo">
<div id="logo_text">
<!-- class="logo_colour", allows you to change the colour of the text -->
<h1><a href="index.html">Afa<span class="logo_colour">sie</span></a></h1>
<h2>Leer meer over Afasie.</h2>
</div>
</div>
<div id="menubar">
<ul id="menu"><!-- put class="selected" in the li tag for the selected page - to highlight which page you're on --><li><a href="index.html">Home</a></li>
<li><a href="informatie.html">Informatie</a></li>
<li><a href="oefenen.php">Oefenen</a></li>
<li><a href="scorelijst.php">Scorelijst</a></li>
<li><a href="gebruikerslijst.php">Gebruikerslijst</a></li>
<li><a href="inloggen.php">Inloggen</a></li>
<li><a href="registreren.php">Registreren</a></li>
<li><a href="contact.html">Contact</a></li>
</ul></div>
</div>
<div id="content_header"></div>
<div id="site_content">
<div id="sidebar_container">
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
<!-- insert your sidebar items here -->
</div>
<div class="sidebar_base"></div>
</div>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
</ul></div>
<div class="sidebar_base"></div>
</div>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
</div>
<div class="sidebar_base"></div>
</div>
</div>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="inlogcheck.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Inloggen </strong></td>
</tr>
<tr>
<td width="78">Gebruikersnaam</td>
<td width="6">:</td>
<td width="294"><input name="Inlognaam" type="text" id="Inlognaam"></td>
</tr>
<tr>
<td>Wachtwoord</td>
<td>:</td>
<td><input name="Wachtwoord" type="password" id="Wachtwoord"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</div>
<div id="content_footer"></div>
<div id="footer">
<p><a href="index.html">Home</a> | <a href="informatie.html">Informatie</a> | <a href="oefenen.html">Oefenen</a> | <a href="scorelijst.php">Scorelijst</a> | <a href="gebruikerslijst.php">Gebruikerslijst</a> | <a href="inloggen.php">Inloggen</a> | <a href="registreren.php">Registreren</a> | <a href="contact.html">Contact</a></p>
</p>
</div>
</div>
</body></html>
ingelogd.php
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
session_start();
$a = $_SESSION["Inlognaam"];
$b = $_SESSION["Wachtwoord"];
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
echo "Je huidige sessieID is <strong>".session_id() . "</strong>";
?>
session_start();
$a = $_SESSION["Inlognaam"];
$b = $_SESSION["Wachtwoord"];
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
echo "Je huidige sessieID is <strong>".session_id() . "</strong>";
?>
<html>
<body>
Login Successful
</body>
</html>
Gewijzigd op 10/09/2012 14:35:05 door Hendrik Wit
$_SESSION("Wachtwoord") = $Wachtwoord;
$_SESSION is een array en geen functie, dus:
$_SESSION["Inlognaam"] = $Inlognaam;
$_SESSION["Wachtwoord"] = $Wachtwoord;