Probleem met php scripten .
Dus als ik de admin check doe dan werkt hij niet de admins kunnen niet op de pagina.
Kan iemand me helpen met het te fixen.
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
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
<?php
session_start(); // Start your sessions to allow your page to interact with session variables
include_once("connect.php");
// Check to see if they person accessing this page is logged in and that there is a category id in the url
if ((!isset($_SESSION['uid']))) {
header("Location: index.php");
exit();
}
// Function that will convert a user id into their Permission
function getpermission($uid) {
$sql = "SELECT Permission FROM users WHERE id='".$uid."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
return $row['Permission'];
}
$uid = $_SESSION[uid];
$permission = '$getpermission($uid)';
$admin = 'admin';
if ($permission!=$admin) {
header("Location: index.php");
exit();
}
include_once("header.php");
include_once("sidebar.php");
echo "go back to <a href='index.php'>forum index</a> - <a href='admin.php'>admin index</a>";
include_once("footer.php");
?>
session_start(); // Start your sessions to allow your page to interact with session variables
include_once("connect.php");
// Check to see if they person accessing this page is logged in and that there is a category id in the url
if ((!isset($_SESSION['uid']))) {
header("Location: index.php");
exit();
}
// Function that will convert a user id into their Permission
function getpermission($uid) {
$sql = "SELECT Permission FROM users WHERE id='".$uid."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
return $row['Permission'];
}
$uid = $_SESSION[uid];
$permission = '$getpermission($uid)';
$admin = 'admin';
if ($permission!=$admin) {
header("Location: index.php");
exit();
}
include_once("header.php");
include_once("sidebar.php");
echo "go back to <a href='index.php'>forum index</a> - <a href='admin.php'>admin index</a>";
include_once("footer.php");
?>
De inhoud van Permission in de database, is dat bij een administrator 'admin' ?... als dit niet het geval is namelijk gaat 'if ($permission!=$admin)' op regel 45 altijd TRUE teruggeven en dus naar de index.php verwijzen.
regel 11 kan je twee haakjes weghalen, dus dan wordt het zo:
Gewijzigd op 15/05/2013 14:20:58 door Marvin H
Moet zijn:
$permission = getpermission($uid);
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
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
<?php
session_start(); // Start your sessions to allow your page to interact with session variables
include_once("connect.php");
// Check to see if they person accessing this page is logged in and that there is a category id in the url
if ((!isset($_SESSION['uid']))) {
header("Location: index.php");
exit();
}
// Function that will convert a user id into their Permission
function getpermission($uid) {
$sql = "SELECT Permission FROM users WHERE id='".$uid."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
return $row['Permission'];
}
$uid = $_SESSION[uid];
$permission = getpermission($uid);
$admin = 'admin';
if ($permission!=$admin) {
header("Location: index.php");
exit();
}
include_once("header.php");
include_once("sidebar.php");
echo "go back to <a href='index.php'>forum index</a> - <a href='admin.php'>admin index</a>";
include_once("footer.php");
?>
session_start(); // Start your sessions to allow your page to interact with session variables
include_once("connect.php");
// Check to see if they person accessing this page is logged in and that there is a category id in the url
if ((!isset($_SESSION['uid']))) {
header("Location: index.php");
exit();
}
// Function that will convert a user id into their Permission
function getpermission($uid) {
$sql = "SELECT Permission FROM users WHERE id='".$uid."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
return $row['Permission'];
}
$uid = $_SESSION[uid];
$permission = getpermission($uid);
$admin = 'admin';
if ($permission!=$admin) {
header("Location: index.php");
exit();
}
include_once("header.php");
include_once("sidebar.php");
echo "go back to <a href='index.php'>forum index</a> - <a href='admin.php'>admin index</a>";
include_once("footer.php");
?>
Fatal error: Call to undefined function phpsession_start() in /home/vol14/xtreemhost.com/xth_13129488/knightsofedvar.xtreemhost.com/htdocs/admin.php on line 1
Toevoeging op 15/05/2013 14:44:42:
Code werkt tnx ;)
Gewijzigd op 15/05/2013 14:39:15 door Jasper De Moor
Jasper De Moor op 15/05/2013 14:37:39:
Fatal error: Call to undefined function phpsession_start() in /home/vol14/xtreemhost.com/xth_13129488/knightsofedvar.xtreemhost.com/htdocs/admin.php on line 1
Dit komt omdat je waarschijnlijk je < ?php en session_start(); op één regel aan elkaar hebt staan:
moet zijn
Gewijzigd op 15/05/2013 14:46:11 door Marvin H
Jasper De Moor op 15/05/2013 14:37:39:
werkt niet -_-
Kan niemand iets mee.
Jasper De Moor op 15/05/2013 14:37:39:
Fatal error: Call to undefined function phpsession_start() in /home/vol14/xtreemhost.com/xth_13129488/knightsofedvar.xtreemhost.com/htdocs/admin.php on line 1
Lijkt mij duidelijk genoeg.
- SanThe - op 15/05/2013 14:47:13:
Kan niemand iets mee.
Lijkt mij duidelijk genoeg.
Jasper De Moor op 15/05/2013 14:37:39:
werkt niet -_-
Kan niemand iets mee.
Jasper De Moor op 15/05/2013 14:37:39:
Fatal error: Call to undefined function phpsession_start() in /home/vol14/xtreemhost.com/xth_13129488/knightsofedvar.xtreemhost.com/htdocs/admin.php on line 1
Lijkt mij duidelijk genoeg.
Je mist volgens mij de quotes.
$uid = $_SESSION["uid"];
Ik heb al gezegd dat het gefixt is ;)