IP adres niet opgeslagen in database?
Het IP adres en de browser gegevens worden niet opgeslagen in de database en zou wel moeten, ik heb geen idee waar het probleem zit. Krijg ook geen foutmelding...
De rest van de gegevens worden wel in de database opgeslagen...
name (wel) (door de gebruiker ingevoerd)
email (wel) (door de gebruiker ingevoerd)
icq (wel) (door de gebruiker ingevoerd)
http (wel) (door de gebruiker ingevoerd)
message (wel) (door de gebruiker ingevoerd)
timestamp (wel) (via php automatisch)
ip (niet) (via php automatisch)
location (wel) (door de gebruiker ingevoerd)
browser (niet) (via php automatisch)
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
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
<?php
########################################
# Process
########################################
if ($action=="submit") { // Add an action
if (!$in && !$delid && !$delcommentid && !$commentid) {
header("Location: $PHP_SELF");
exit;
} elseif ($delid && $admin==$adminpass) {
mysql_db_query($database, "DELETE FROM guestbook WHERE id='$delid'") or died("mysql_error()");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($delcommentid && $admin==$adminpass) {
mysql_db_query($database, "UPDATE guestbook SET comment='' where id='$delcommentid'") or died("mysql_error()");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($commentid && $admin==$adminpass) {
if(isset($comment)){
$action=changed;
mysql_db_query($database, "UPDATE guestbook SET comment='".encode_msg($comment)."' where id='$commentid'") or died("mysql_error()");
} else {
$action="";
}
header("Location: $PHP_SELF?commentid=$commentid&action=$action&offset=$offset&poffset=$poffset&admin=$admin");
exit;
} else {
if (isbanned()) {
header("Location: $PHP_SELF");
exit;
}
$add_date=time();
$result=mysql_db_query($database, "SELECT * FROM guestbook WHERE ip='$REMOTE_ADDR' AND timestamp>($add_date-(60*$timelimit))") or died("mysql_error()");
$query=mysql_fetch_array($result);
if ($query) {
header("Location: $PHP_SELF");
exit;
}
$in = strip_array($in);
$in['message'] = encode_msg($in['message']); // Add SQL compatibilty & Smilie Convert
$in['http'] = str_replace("http://", "", $in['http']); // Remove http:// from URLs
if ($in['name'] == "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$name_empty</center></body></html>"); }
if ($in['icq'] != "" && ($in['icq'] < 1000 || $in['icq'] > 999999999)) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$icq_wrong</center></body></html>"); }
if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$in['email']) && $in['email'] != "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$non_valid_email</center></body></html>"); }
if (strlen($in['message']) < $limit["0"] || strlen($in['message']) > $limit["1"]) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$message_incorrect $limit[0] $and $limit[1] $characters.</center></body></html>"); }
if ($in['email'] == "") { $in['email'] = "none"; }
if ($in['icq'] == "") { $in['icq'] = 0; }
if ($in['http'] == "") { $in['http'] = "none"; }
if ($in['location'] == "0") { $in['location'] = "none"; }
$in['browser'] = $HTTP_USER_AGENT;
mysql_db_query($database, "INSERT INTO guestbook (name, email, http, icq, message, timestamp, ip, location, browser)
VALUES('$in[name]', '$in[email]','$in[http]','$in[icq]','$in[message]','$add_date', '$REMOTE_ADDR','$in[location]','$in[browser]')")
or died("mysql_error()");
if ($gb_notify) {
@mail("$gb_notify","$gb_notifysubj","$notify_text $in[name]\n\n".censor_msg($in[message]),"From: $gb_notify");
}
if ($timelimit) {
setcookie("phpbookcookie","$guestbook_head", time()+(60*$timelimit),"/");
}
if ($admin) {$adminlink="?admin=$admin";}
header("Location: $PHP_SELF$adminlink");
exit;
}
} else { // Show the entries
?>
########################################
# Process
########################################
if ($action=="submit") { // Add an action
if (!$in && !$delid && !$delcommentid && !$commentid) {
header("Location: $PHP_SELF");
exit;
} elseif ($delid && $admin==$adminpass) {
mysql_db_query($database, "DELETE FROM guestbook WHERE id='$delid'") or died("mysql_error()");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($delcommentid && $admin==$adminpass) {
mysql_db_query($database, "UPDATE guestbook SET comment='' where id='$delcommentid'") or died("mysql_error()");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($commentid && $admin==$adminpass) {
if(isset($comment)){
$action=changed;
mysql_db_query($database, "UPDATE guestbook SET comment='".encode_msg($comment)."' where id='$commentid'") or died("mysql_error()");
} else {
$action="";
}
header("Location: $PHP_SELF?commentid=$commentid&action=$action&offset=$offset&poffset=$poffset&admin=$admin");
exit;
} else {
if (isbanned()) {
header("Location: $PHP_SELF");
exit;
}
$add_date=time();
$result=mysql_db_query($database, "SELECT * FROM guestbook WHERE ip='$REMOTE_ADDR' AND timestamp>($add_date-(60*$timelimit))") or died("mysql_error()");
$query=mysql_fetch_array($result);
if ($query) {
header("Location: $PHP_SELF");
exit;
}
$in = strip_array($in);
$in['message'] = encode_msg($in['message']); // Add SQL compatibilty & Smilie Convert
$in['http'] = str_replace("http://", "", $in['http']); // Remove http:// from URLs
if ($in['name'] == "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$name_empty</center></body></html>"); }
if ($in['icq'] != "" && ($in['icq'] < 1000 || $in['icq'] > 999999999)) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$icq_wrong</center></body></html>"); }
if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$in['email']) && $in['email'] != "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$non_valid_email</center></body></html>"); }
if (strlen($in['message']) < $limit["0"] || strlen($in['message']) > $limit["1"]) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$message_incorrect $limit[0] $and $limit[1] $characters.</center></body></html>"); }
if ($in['email'] == "") { $in['email'] = "none"; }
if ($in['icq'] == "") { $in['icq'] = 0; }
if ($in['http'] == "") { $in['http'] = "none"; }
if ($in['location'] == "0") { $in['location'] = "none"; }
$in['browser'] = $HTTP_USER_AGENT;
mysql_db_query($database, "INSERT INTO guestbook (name, email, http, icq, message, timestamp, ip, location, browser)
VALUES('$in[name]', '$in[email]','$in[http]','$in[icq]','$in[message]','$add_date', '$REMOTE_ADDR','$in[location]','$in[browser]')")
or died("mysql_error()");
if ($gb_notify) {
@mail("$gb_notify","$gb_notifysubj","$notify_text $in[name]\n\n".censor_msg($in[message]),"From: $gb_notify");
}
if ($timelimit) {
setcookie("phpbookcookie","$guestbook_head", time()+(60*$timelimit),"/");
}
if ($admin) {$adminlink="?admin=$admin";}
header("Location: $PHP_SELF$adminlink");
exit;
}
} else { // Show the entries
?>
Gewijzigd op 01/01/1970 01:00:00 door Edwin Schoonbeek
Sorry ff vergeten... nu is het goed... :-)
geeft
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/web1484/html/guest/guestbook.php on line 74
NEE NOG FOUT>>
probeer
='" . $_SERVER['REMOTE_ADDR'] . "'
Gewijzigd op 01/01/1970 01:00:00 door nvt nvt
Heb het erin staan maar hij slaat het nog niet op...
Code (php)
1
2
3
4
5
2
3
4
5
<?php
$hetip = $_SERVER['REMOTE_ADDR'];
//dit is dat stukje uit insert
'$add_date', '".$hetip."','$in[location]'
?>
$hetip = $_SERVER['REMOTE_ADDR'];
//dit is dat stukje uit insert
'$add_date', '".$hetip."','$in[location]'
?>
Gewijzigd op 01/01/1970 01:00:00 door nvt nvt
Jan Koehoorn schreef op 28.04.2007 21:08:
Probeer eens zo Edwin:
Code (php)
Waar plaats ik dit precies?
CREATE TABLE `guestbook` (
`id` int(5) NOT NULL auto_increment,
`name` varchar(25) NOT NULL default '',
`email` varchar(35) NOT NULL default '',
`icq` int(11) NOT NULL default '0',
`http` varchar(50) NOT NULL default '',
`message` mediumtext NOT NULL,
`timestamp` int(11) NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`location` varchar(35) NOT NULL default '',
`browser` varchar(50) NOT NULL default '',
`comment` mediumtext NOT NULL,
PRIMARY KEY (`id`),
KEY `location` (`location`),
FULLTEXT KEY `ip` (`ip`),
FULLTEXT KEY `ip_2` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=324 ;
Edwin Schoonbeek schreef op 28.04.2007 21:14:
Waar plaats ik dit precies?
Uit die vraag maak ik op dat je nog niet erg op de hoogte bent met PHP. Het is gewoon een functie die een ip-adres teruggeeft. Die plaats je dus in je script voordat je de insert query uitvoert.
Mooi scriptje trouwens Jan, bij mij werkte de REMOTE-ADRR niet. Met dit scriptje werkt het wel:) Meteen in de class voor het inloggen gezet