Inlog werkt maar half
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<link href="css/cms_style.css" rel="stylesheet" type="text/css" />
<link href="css/login.css" rel="stylesheet" type="text/css" />
<div class="logo_B">
<div class="logo"></div>
</div>
<br /><br /><br /><br /><br />
<div class="logintitel1">Login</div>
<br /><div class="hr"></div>
<br />
<div class="loginbox1">
<div class="loginboxinner1">
H
</div></div>
<div class="logintitel"> inloggen </div>
<div class="loginbox"><div class="loginboxinner">
<form name="login_form" method="post" action="login2.php">
<div class="loglinks"> Gebruikersnaam</div><div class="logrechts"><input name="user" type="text" id="user" size="35">
</div>
<div class="loglinks"> Wachtwoord </div><div class="logrechts"> <input name="pass" type="password" id="pass" size="35"></div>
<div class="loglinks"><input type="submit" name="login" id="login" value="Login"></div>
</p>
</form>
</div></div>
<link href="css/login.css" rel="stylesheet" type="text/css" />
<div class="logo_B">
<div class="logo"></div>
</div>
<br /><br /><br /><br /><br />
<div class="logintitel1">Login</div>
<br /><div class="hr"></div>
<br />
<div class="loginbox1">
<div class="loginboxinner1">
H
</div></div>
<div class="logintitel"> inloggen </div>
<div class="loginbox"><div class="loginboxinner">
<form name="login_form" method="post" action="login2.php">
<div class="loglinks"> Gebruikersnaam</div><div class="logrechts"><input name="user" type="text" id="user" size="35">
</div>
<div class="loglinks"> Wachtwoord </div><div class="logrechts"> <input name="pass" type="password" id="pass" size="35"></div>
<div class="loglinks"><input type="submit" name="login" id="login" value="Login"></div>
</p>
</form>
</div></div>
login2.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
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
<?php
session_start();
require_once 'config.php';
# make a variable out of the username that was posted in the index-page.
$username = $_POST['user'];
# I am not sure what this thing makes.. but it has something with safety to do.
$escaped_username = mysql_real_escape_string($username);
# make a md5 password.
$md5_password = md5($_POST['pass']);
$queryN = mysql_query("select * from user where username = '".$username."' and password = '".$md5_password."'
AND level='1'");#This variable will check if the user is a level 1 user (Normal User)
$queryA = mysql_query("select * from user where username = '".$username."' and password = '".$md5_password."'
AND level='2'");#This variable will check if the user is a level 9 user (Admin User)
if(mysql_num_rows($queryN) == 1)
{
$resultN = mysql_fetch_assoc($queryN);
$_SESSION['user'] = $_POST['user'];
header("location:admin/index.php");
}
elseif(mysql_num_rows($queryA) == 1)
{
$resultA = mysql_fetch_assoc($queryA);
$_SESSION['admin'] = $_POST['user'];
header("location:admin/index.php");
}
else{
echo "Wrong Username or Password";
}
?>
<form name="back" method="post" action="index.php">
<input type="submit" name="back" id="back" value="Back to Home">
session_start();
require_once 'config.php';
# make a variable out of the username that was posted in the index-page.
$username = $_POST['user'];
# I am not sure what this thing makes.. but it has something with safety to do.
$escaped_username = mysql_real_escape_string($username);
# make a md5 password.
$md5_password = md5($_POST['pass']);
$queryN = mysql_query("select * from user where username = '".$username."' and password = '".$md5_password."'
AND level='1'");#This variable will check if the user is a level 1 user (Normal User)
$queryA = mysql_query("select * from user where username = '".$username."' and password = '".$md5_password."'
AND level='2'");#This variable will check if the user is a level 9 user (Admin User)
if(mysql_num_rows($queryN) == 1)
{
$resultN = mysql_fetch_assoc($queryN);
$_SESSION['user'] = $_POST['user'];
header("location:admin/index.php");
}
elseif(mysql_num_rows($queryA) == 1)
{
$resultA = mysql_fetch_assoc($queryA);
$_SESSION['admin'] = $_POST['user'];
header("location:admin/index.php");
}
else{
echo "Wrong Username or Password";
}
?>
<form name="back" method="post" action="index.php">
<input type="submit" name="back" id="back" value="Back to Home">
kijk hij wil nu wel users inloggen met de level 1 maar als ik level 2 doe dan gaat hij automatich weer terug naar de index en dat wil ik niet. Ik kom er niet uit kan iemand mij helpen ?
Gewijzigd op 01/01/1970 01:00:00 door Niels van Dijk
uhhj
edit:
Waar slaat dit dan op ..
Code (php)
1
2
2
<form name="back" method="post" action="index.php">
<input type="submit" name="back" id="back" value="Back to Home">
<input type="submit" name="back" id="back" value="Back to Home">
Gewijzigd op 01/01/1970 01:00:00 door Jaron T
:D maar dat heb ik al veranderd:P
*edit*
dat is niets
Gewijzigd op 01/01/1970 01:00:00 door Niels van Dijk
Verder heb je een hoop overbodige regels.
Regel 6, 8 en 10 kunnen weg want dat kan in één keer direct in de query.
Regel 12 en 15 voeren query's uit waarvan er één overbodig zal zijn.
Regel 21 en 29 zijn overbodig want daar doe je verder niks mee.
Foutafhandeling ontbreekt.
ik had
$_SESSION['admin'] = $_POST['user'];
dat dit moetst worden
$_SESSION['user'] = $_POST['user'];