inlog-systeem-zonder-cookies-of-sessions
Gesponsorde koppelingen
PHP script bestanden
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
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
<?
// gebruik de volgende table voor mysql
CREATE TABLE user (
userid int(11) NOT NULL auto_increment,
username varchar(12) NOT NULL DEFAULT '' ,
userpass varchar(32) NOT NULL DEFAULT '' ,
sesid varchar(32) NOT NULL DEFAULT '' ,
time int(14) NOT NULL DEFAULT '0' ,
PRIMARY KEY (userid),
INDEX userid (userid)
);
//-------
// ---->> functions.php <<----
//-------
// wijzig dit in je eigen database gegevens
mysql_connect("localhost","root","");
mysql_select_db("test");
function user_check(){
global $username,$userpass,$gonder,$time;
$check_user = @mysql_query("SELECT userid FROM user WHERE username = '$username' AND userpass = '".md5($userpass)."'");
$row = mysql_fetch_array($check_user);
$userid = $row["userid"];
if (!empty($userid)) {
//genereerd de sessie en de tijd wanneer hij ongeldig word
$sesid = md5(time());
$time = time() + 360;
@mysql_query("UPDATE user SET sesid='$sesid',time='$time' WHERE userid='$userid'");
// in plaats van sessies en cookies gebruik ik sesid
header("Location:secret.php?sesid=$sesid");
} else {
echo die("<center>Fout paswoord of login naam, probeer het <a href=login.php>opnieuw</a>...</center>");
}
}
function session_check() {
global $sesid;
$check_time = @mysql_query("SELECT zaman FROM user WHERE sesid = '$sesid'");
$time_row = @mysql_fetch_array($check_time);
$bitis = $time_row["time"];
if ($bitis < time()){
die("<center>Timeout! Probeer het <a href=login.php>opnieuw/a>...</center>");
}
}
?>
// gebruik de volgende table voor mysql
CREATE TABLE user (
userid int(11) NOT NULL auto_increment,
username varchar(12) NOT NULL DEFAULT '' ,
userpass varchar(32) NOT NULL DEFAULT '' ,
sesid varchar(32) NOT NULL DEFAULT '' ,
time int(14) NOT NULL DEFAULT '0' ,
PRIMARY KEY (userid),
INDEX userid (userid)
);
//-------
// ---->> functions.php <<----
//-------
// wijzig dit in je eigen database gegevens
mysql_connect("localhost","root","");
mysql_select_db("test");
function user_check(){
global $username,$userpass,$gonder,$time;
$check_user = @mysql_query("SELECT userid FROM user WHERE username = '$username' AND userpass = '".md5($userpass)."'");
$row = mysql_fetch_array($check_user);
$userid = $row["userid"];
if (!empty($userid)) {
//genereerd de sessie en de tijd wanneer hij ongeldig word
$sesid = md5(time());
$time = time() + 360;
@mysql_query("UPDATE user SET sesid='$sesid',time='$time' WHERE userid='$userid'");
// in plaats van sessies en cookies gebruik ik sesid
header("Location:secret.php?sesid=$sesid");
} else {
echo die("<center>Fout paswoord of login naam, probeer het <a href=login.php>opnieuw</a>...</center>");
}
}
function session_check() {
global $sesid;
$check_time = @mysql_query("SELECT zaman FROM user WHERE sesid = '$sesid'");
$time_row = @mysql_fetch_array($check_time);
$bitis = $time_row["time"];
if ($bitis < time()){
die("<center>Timeout! Probeer het <a href=login.php>opnieuw/a>...</center>");
}
}
?>
//-------
// ---->> login.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
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
<?
include("functions.php");
if (!empty($submit)){
user_check();
} else {
echo "<form action=login.php method=post>";
echo "<table width=350 border=0 cellpadding=1 cellspacing=0 align=center>";
echo "<tr>";
echo "<td width=200>Login naam :</td><td><input type=text name=username size=15></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=200>Paswoord :</td><td><input type=password name=userpass size=15></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=200> </td><td><input type=submit name=submit value=Inloggen></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
//-------
// ---->> secret.php <<----
//-------
include("functions.php");
// bekijk sessie id en tijd
session_check();
// laat de content zien
echo "<center>Zet je hier geheime pagina neer Vergeet niet \$sesid achter je url's te doen (dus pagina.php?sesid=\$sesid)";
?>
include("functions.php");
if (!empty($submit)){
user_check();
} else {
echo "<form action=login.php method=post>";
echo "<table width=350 border=0 cellpadding=1 cellspacing=0 align=center>";
echo "<tr>";
echo "<td width=200>Login naam :</td><td><input type=text name=username size=15></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=200>Paswoord :</td><td><input type=password name=userpass size=15></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=200> </td><td><input type=submit name=submit value=Inloggen></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
//-------
// ---->> secret.php <<----
//-------
include("functions.php");
// bekijk sessie id en tijd
session_check();
// laat de content zien
echo "<center>Zet je hier geheime pagina neer Vergeet niet \$sesid achter je url's te doen (dus pagina.php?sesid=\$sesid)";
?>