cookies in IE
in firefox kan ik inloggen.en worden alle sessies en cookies aangemaakt.(zie bovenaan de website), maar in internet explorer lukt dit echter niet!
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
32
33
34
35
36
37
38
39
40
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
function login($data){
$data['nickname']=htmlspecialchars($data['nickname']);
$data['nickname']=addslashes($data['nickname']);
$data['password']=md5(htmlspecialchars($data['password']));
$query="SELECT*FROM fans WHERE nickname='".$data['nickname']."' AND password='".$data['password']."'";
if($r=mysql_query($query)){
if(mysql_num_rows($r)==1){
$row=mysql_fetch_array($r);
//set session fan id
$_SESSION['fan_id']=$row['fan_id'];
//set key
$key=random_pass(80);
$query="UPDATE fans SET loginkey='".$key."' WHERE fan_id='".$row['fan_id']."'";
if(!mysql_query($query)){
print mysql_error();
}
//set cookie
if(!setcookie('loginkey',$key,time()+3600*24*100)){
print'Problems with setting the cookie!';
}
//send to news page
print $_SESSION['fan_id'].' '.$key;
print'<br>U bent succesvol ingelogd. U wordt binnen 3 seconden doorverwezen naar de home pagina.';
header('Refresh: 3; URL=news.php');
}else{
header('location:login.php?wrong');
}
}
}
if(isset($_GET['wrong'])){
print'<font color="#FF0000"><b>Wrong Login! Please try again.</b></font><br>';
}
$form=new FormHandler();
$form->TextField('Nickname','nickname',FH_STRING);
$form->PassField('Password','password',FH_STRING);
$form->OnCorrect('login');
$form->SubmitButton('login');
$form->flush();
$data['nickname']=htmlspecialchars($data['nickname']);
$data['nickname']=addslashes($data['nickname']);
$data['password']=md5(htmlspecialchars($data['password']));
$query="SELECT*FROM fans WHERE nickname='".$data['nickname']."' AND password='".$data['password']."'";
if($r=mysql_query($query)){
if(mysql_num_rows($r)==1){
$row=mysql_fetch_array($r);
//set session fan id
$_SESSION['fan_id']=$row['fan_id'];
//set key
$key=random_pass(80);
$query="UPDATE fans SET loginkey='".$key."' WHERE fan_id='".$row['fan_id']."'";
if(!mysql_query($query)){
print mysql_error();
}
//set cookie
if(!setcookie('loginkey',$key,time()+3600*24*100)){
print'Problems with setting the cookie!';
}
//send to news page
print $_SESSION['fan_id'].' '.$key;
print'<br>U bent succesvol ingelogd. U wordt binnen 3 seconden doorverwezen naar de home pagina.';
header('Refresh: 3; URL=news.php');
}else{
header('location:login.php?wrong');
}
}
}
if(isset($_GET['wrong'])){
print'<font color="#FF0000"><b>Wrong Login! Please try again.</b></font><br>';
}
$form=new FormHandler();
$form->TextField('Nickname','nickname',FH_STRING);
$form->PassField('Password','password',FH_STRING);
$form->OnCorrect('login');
$form->SubmitButton('login');
$form->flush();
en dan de pagina die bovenaan elke pagina wordt geinclude:
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if(!empty($_COOKIE['loginkey']) AND !isset($_SESSION['fan_id'])){
$query="SELECT*FROM fans WHERE loginkey='".$_COOKIE['loginkey']."' LIMIT 1";
if($r=mysql_query($query)){
if(mysql_num_rows($r)==1){
$row=mysql_fetch_array($r);
$_SESSION['fan_id']=$row['fan_id'];
}
}else{
print mysql_error();
}
}
if(isset($_SESSION['fan_id']) AND is_numeric($_SESSION['fan_id'])){
if(!isset($_COOKIE['loginkey'])){
//print'Cookies are not enabled!<br>';
}
$finfo=faninfo($_SESSION['fan_id']);
print'Welkom '.$finfo['nickname'].' - <a href="myprofile.php">Mijn Profiel</a> - <a href="logout.php">Log uit</a>';
$flogin=1;
}else{
print'<a href="login.php">Log in</a> - <a href="register.php">Registreer</a>';
$flogin=0;
}
$query="SELECT*FROM fans WHERE loginkey='".$_COOKIE['loginkey']."' LIMIT 1";
if($r=mysql_query($query)){
if(mysql_num_rows($r)==1){
$row=mysql_fetch_array($r);
$_SESSION['fan_id']=$row['fan_id'];
}
}else{
print mysql_error();
}
}
if(isset($_SESSION['fan_id']) AND is_numeric($_SESSION['fan_id'])){
if(!isset($_COOKIE['loginkey'])){
//print'Cookies are not enabled!<br>';
}
$finfo=faninfo($_SESSION['fan_id']);
print'Welkom '.$finfo['nickname'].' - <a href="myprofile.php">Mijn Profiel</a> - <a href="logout.php">Log uit</a>';
$flogin=1;
}else{
print'<a href="login.php">Log in</a> - <a href="register.php">Registreer</a>';
$flogin=0;
}
Ik zou zeggen. ga eens kijken naar de url. en probeer in te loggen met
nickname: test
paswoord: phphulp
dank bij voorbaad
Er zijn nog geen reacties op dit bericht.