Aantal undefined fouten!
De fouten zijn:
Notice: Undefined variable: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 33
Notice: Undefined variable: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 36
Notice: Undefined variable: all in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 47
Notice: Use of undefined constant name_id_c - assumed 'name_id_c' in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 119
Notice: Undefined index: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 119
Notice: Use of undefined constant link_c - assumed 'link_c' in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 124
Notice: Undefined index: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 124
Notice: Undefined variable: php_self in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 129
Notice: Undefined variable: add in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 139
Het stukje script waar het omgaat is de volgende:
Code (php)
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<body onload="window.scrollTo(0,99999);">
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
71
72
73
74
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
71
72
73
74
<?
include("connect.php");
$result = mysql_query("SELECT * FROM shout");
$all_rows = mysql_num_rows($result);
if ($all == "true"){
$start = "0";
$posts = "999";
} else {
if ($all_rows < 15){
$start = "0";
} else {
$start = $all_rows - 15;
}
$posts = "15";
}
$result = mysql_query("SELECT * FROM shout ORDER BY time ASC LIMIT $start,$posts");
$rows = mysql_num_rows($result);
if ($rows > 0) {
while($row = mysql_fetch_array($result)){
// Bad word check
$badwords = mysql_query("SELECT * FROM badwords");
$rowords = mysql_fetch_array($badwords);
$words = explode(",", $rowords[words]);
$bad = "*********************";
$i = "0";
while ($words[$i]){
$length = strlen($words[$i])-2;
$bad = substr($words[$i], 0, 2) . substr($bad, -$length);
$row[text] = ereg_replace($words[$i],$bad, $row[text]);
$i++;
}
// End of bad word check
$time = date("d. F Y H:i",$row[time]);
// Change emotions
$smile = "<img src='images/shout/happy.gif' align='absmiddle'>";
$ironic = "<img src='images/shout/ironic.gif' align='absmiddle'>";
$nothappy = "<img src='images/shout/mad.gif' align='absmiddle'>";
$very_happy = "<img src='images/shout/very_happy.gif' align='absmiddle'>";
$tongue = "<img src='images/shout/tongue.gif' align='absmiddle'>";
$nothing = "<img src='images/shout/nothing.gif' align='absmiddle'>";
$vain = "<img src='images/shout/vain.gif' align='absmiddle'>";
$row[text] = ereg_replace(":-\/",$vain, $row[text]);
$row[text] = ereg_replace(":\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-P",$tongue, $row[text]);
$row[text] = ereg_replace(":P",$tongue, $row[text]);
$row[text] = ereg_replace(":p",$tongue, $row[text]);
$row[text] = ereg_replace(":-p",$tongue, $row[text]);
$row[text] = ereg_replace(":)",$smile, $row[text]);
$row[text] = ereg_replace(":-)",$smile, $row[text]);
$row[text] = ereg_replace(":D",$very_happy, $row[text]);
$row[text] = ereg_replace(":-D",$very_happy, $row[text]);
$row[text] = ereg_replace(":\(",$nothappy, $row[text]);
$row[text] = ereg_replace(":-\(",$nothappy, $row[text]);
$row[text] = ereg_replace(";)",$ironic, $row[text]);
$row[text] = ereg_replace(";-)",$ironic, $row[text]);
if ($row[ip] != "") {
$logged = "Yes!";
} else {
$logged = "No";
}
echo "<table cellpadding='2' cellspacing='0' width='100%'><tr><td align='left'>";
$amounts = mysql_query("SELECT * FROM shout WHERE ip = '$row[ip]'");
$entries = mysql_num_rows($amounts);
if ($row[link] != ""){
echo "<a target='_blank' href='http://$row[link]' title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </a>";
} else {
echo "<b title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </b></a>";
}
echo "$row[text]";
echo "</td></tr></table>";
}
}
?>
include("connect.php");
$result = mysql_query("SELECT * FROM shout");
$all_rows = mysql_num_rows($result);
if ($all == "true"){
$start = "0";
$posts = "999";
} else {
if ($all_rows < 15){
$start = "0";
} else {
$start = $all_rows - 15;
}
$posts = "15";
}
$result = mysql_query("SELECT * FROM shout ORDER BY time ASC LIMIT $start,$posts");
$rows = mysql_num_rows($result);
if ($rows > 0) {
while($row = mysql_fetch_array($result)){
// Bad word check
$badwords = mysql_query("SELECT * FROM badwords");
$rowords = mysql_fetch_array($badwords);
$words = explode(",", $rowords[words]);
$bad = "*********************";
$i = "0";
while ($words[$i]){
$length = strlen($words[$i])-2;
$bad = substr($words[$i], 0, 2) . substr($bad, -$length);
$row[text] = ereg_replace($words[$i],$bad, $row[text]);
$i++;
}
// End of bad word check
$time = date("d. F Y H:i",$row[time]);
// Change emotions
$smile = "<img src='images/shout/happy.gif' align='absmiddle'>";
$ironic = "<img src='images/shout/ironic.gif' align='absmiddle'>";
$nothappy = "<img src='images/shout/mad.gif' align='absmiddle'>";
$very_happy = "<img src='images/shout/very_happy.gif' align='absmiddle'>";
$tongue = "<img src='images/shout/tongue.gif' align='absmiddle'>";
$nothing = "<img src='images/shout/nothing.gif' align='absmiddle'>";
$vain = "<img src='images/shout/vain.gif' align='absmiddle'>";
$row[text] = ereg_replace(":-\/",$vain, $row[text]);
$row[text] = ereg_replace(":\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-P",$tongue, $row[text]);
$row[text] = ereg_replace(":P",$tongue, $row[text]);
$row[text] = ereg_replace(":p",$tongue, $row[text]);
$row[text] = ereg_replace(":-p",$tongue, $row[text]);
$row[text] = ereg_replace(":)",$smile, $row[text]);
$row[text] = ereg_replace(":-)",$smile, $row[text]);
$row[text] = ereg_replace(":D",$very_happy, $row[text]);
$row[text] = ereg_replace(":-D",$very_happy, $row[text]);
$row[text] = ereg_replace(":\(",$nothappy, $row[text]);
$row[text] = ereg_replace(":-\(",$nothappy, $row[text]);
$row[text] = ereg_replace(";)",$ironic, $row[text]);
$row[text] = ereg_replace(";-)",$ironic, $row[text]);
if ($row[ip] != "") {
$logged = "Yes!";
} else {
$logged = "No";
}
echo "<table cellpadding='2' cellspacing='0' width='100%'><tr><td align='left'>";
$amounts = mysql_query("SELECT * FROM shout WHERE ip = '$row[ip]'");
$entries = mysql_num_rows($amounts);
if ($row[link] != ""){
echo "<a target='_blank' href='http://$row[link]' title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </a>";
} else {
echo "<b title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </b></a>";
}
echo "$row[text]";
echo "</td></tr></table>";
}
}
?>
<table width="100%" cellpadding="2" cellspacing="0"><tr><td align="center">
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?
if ($HTTP_COOKIE_VARS[name_id_c]){
$name_value = $HTTP_COOKIE_VARS[name_id_c];
} else {
$name_value = "Your name";
}
if ($HTTP_COOKIE_VARS[link_c]){
$link_value = $HTTP_COOKIE_VARS[link_c];
} else {
$link_value ="Your link";
}
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
if ($HTTP_COOKIE_VARS[name_id_c]){
$name_value = $HTTP_COOKIE_VARS[name_id_c];
} else {
$name_value = "Your name";
}
if ($HTTP_COOKIE_VARS[link_c]){
$link_value = $HTTP_COOKIE_VARS[link_c];
} else {
$link_value ="Your link";
}
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
</td></tr></table>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?
if ($add){
if ($link){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
if ($add){
if ($link){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
</body>
Gewijzigd op 20/09/2005 17:32:00 door Nanne
$_COOKIE['link_c'] en die fout van undifined is dat hij variable link_c enz. niet kan vinden
$array[text] wordt dan dus $array['text']. Maar $array[$i] blijft $array[$i].
Verder, in het laatste deel vanaf if($add){ moeten superglobals worden toegepast. Ik denk dat het voor jezelf geen kwalijke oefening is dit zelf te doen (en ik heb ook nog een hoop andere dingen te doen, je vat m wel). Op deze site, en ook op php.net staat een heleboel over superglobals. Het komt er op neer dat alle variabelen die worden ingesteld door een opgezonden formulier moeten worden hernoemnt van $veldnaam naar $_POST['veldnaam'].
Verder moeten if ($add) en if ($link) even verandert worden naar if(isset($_POST['add'])) en if(isset($_POST['link'])).
Maar vinden jullie het niet gek dat ie het wel prima doet onder linux en niet op een windows server?...
nee, andere versie van php, andere instellingen in php.ini. Heel normaal.
Ok, het probleem is ik ben geen programeur en de host zei dat het 1 op 1 over zou kunnen. Ik ben nu bezig mijn script aan te passen.
Notice: Undefined variable: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 33
Notice: Undefined variable: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 36
Notice: Undefined variable: all in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 47
Notice: Undefined offset: 49 in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 68
Notice: Undefined index: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 119
Notice: Undefined index: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 124
Notice: Undefined variable: php_self in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 129
Het aangepast script is nu:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?
include "connect.php";
mysql_connect($sqlhost,$sqluser,$sqlpass) OR DIE("1");
mysql_select_db($database) OR DIE("1");
?>
include "connect.php";
mysql_connect($sqlhost,$sqluser,$sqlpass) OR DIE("1");
mysql_select_db($database) OR DIE("1");
?>
Code (php)
<link rel="stylesheet" href="../templates/nwp13.css" type="text/css">
<body onload="window.scrollTo(0,99999);">
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
71
72
73
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
71
72
73
<?php
$result = mysql_query("SELECT * FROM shout");
$all_rows = mysql_num_rows($result);
if ($all == "true"){
$start = 0;
$posts = 999;
} else {
if ($all_rows < 15){
$start = "0";
} else {
$start = $all_rows - 15;
}
$posts = "15";
}
$result = mysql_query("SELECT * FROM shout ORDER BY time ASC LIMIT $start,$posts");
$rows = mysql_num_rows($result);
if ($rows > 0) {
while($row = mysql_fetch_array($result)){
// Bad word check
$badwords = mysql_query("SELECT * FROM badwords");
$rowords = mysql_fetch_array($badwords);
$words = explode(",", $rowords['words']);
$bad = "*********************";
$i = "0";
while ($words[$i]){
$length = strlen($words[$i])-2;
$bad = substr($words[$i], 0, 2) . substr($bad, -$length);
$row['text'] = ereg_replace($words[$i],$bad, $row['text']);
$i++;
}
// End of bad word check
$time = date("d. F Y H:i",$row['time']);
// Change emotions
$smile = "<img src='images/shout/happy.gif' align='absmiddle'>";
$ironic = "<img src='images/shout/ironic.gif' align='absmiddle'>";
$nothappy = "<img src='images/shout/mad.gif' align='absmiddle'>";
$very_happy = "<img src='images/shout/very_happy.gif' align='absmiddle'>";
$tongue = "<img src='images/shout/tongue.gif' align='absmiddle'>";
$nothing = "<img src='images/shout/nothing.gif' align='absmiddle'>";
$vain = "<img src='images/shout/vain.gif' align='absmiddle'>";
$row['text'] = ereg_replace(":-\/",$vain, $row['text']);
$row['text'] = ereg_replace(":\|",$nothing, $row['text']);
$row['text'] = ereg_replace(":-\|",$nothing, $row['text']);
$row['text'] = ereg_replace(":-P",$tongue, $row['text']);
$row['text'] = ereg_replace(":P",$tongue, $row['text']);
$row['text'] = ereg_replace(":p",$tongue, $row['text']);
$row['text'] = ereg_replace(":-p",$tongue, $row['text']);
$row['text'] = ereg_replace(":)",$smile, $row['text']);
$row['text'] = ereg_replace(":-)",$smile, $row['text']);
$row['text'] = ereg_replace(":D",$very_happy, $row['text']);
$row['text'] = ereg_replace(":-D",$very_happy, $row['text']);
$row['text'] = ereg_replace(":\(",$nothappy, $row['text']);
$row['text'] = ereg_replace(":-\(",$nothappy, $row['text']);
$row['text'] = ereg_replace(";)",$ironic, $row['text']);
$row['text'] = ereg_replace(";-)",$ironic, $row['text']);
if ($row['ip'] != "") {
$logged = "Yes!";
} else {
$logged = "No";
}
echo "<table cellpadding='2' cellspacing='0' width='100%'><tr><td align='left'>";
$amounts = mysql_query("SELECT * FROM shout WHERE ip = '$row[ip]'");
$entries = mysql_num_rows($amounts);
if ($row['link'] != ""){
echo "<a target='_blank' href='http://$row[link]' title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </a>";
} else {
echo "<b title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </b></a>";
}
echo "$row[text]";
echo "</td></tr></table>";
}
}
?>
$result = mysql_query("SELECT * FROM shout");
$all_rows = mysql_num_rows($result);
if ($all == "true"){
$start = 0;
$posts = 999;
} else {
if ($all_rows < 15){
$start = "0";
} else {
$start = $all_rows - 15;
}
$posts = "15";
}
$result = mysql_query("SELECT * FROM shout ORDER BY time ASC LIMIT $start,$posts");
$rows = mysql_num_rows($result);
if ($rows > 0) {
while($row = mysql_fetch_array($result)){
// Bad word check
$badwords = mysql_query("SELECT * FROM badwords");
$rowords = mysql_fetch_array($badwords);
$words = explode(",", $rowords['words']);
$bad = "*********************";
$i = "0";
while ($words[$i]){
$length = strlen($words[$i])-2;
$bad = substr($words[$i], 0, 2) . substr($bad, -$length);
$row['text'] = ereg_replace($words[$i],$bad, $row['text']);
$i++;
}
// End of bad word check
$time = date("d. F Y H:i",$row['time']);
// Change emotions
$smile = "<img src='images/shout/happy.gif' align='absmiddle'>";
$ironic = "<img src='images/shout/ironic.gif' align='absmiddle'>";
$nothappy = "<img src='images/shout/mad.gif' align='absmiddle'>";
$very_happy = "<img src='images/shout/very_happy.gif' align='absmiddle'>";
$tongue = "<img src='images/shout/tongue.gif' align='absmiddle'>";
$nothing = "<img src='images/shout/nothing.gif' align='absmiddle'>";
$vain = "<img src='images/shout/vain.gif' align='absmiddle'>";
$row['text'] = ereg_replace(":-\/",$vain, $row['text']);
$row['text'] = ereg_replace(":\|",$nothing, $row['text']);
$row['text'] = ereg_replace(":-\|",$nothing, $row['text']);
$row['text'] = ereg_replace(":-P",$tongue, $row['text']);
$row['text'] = ereg_replace(":P",$tongue, $row['text']);
$row['text'] = ereg_replace(":p",$tongue, $row['text']);
$row['text'] = ereg_replace(":-p",$tongue, $row['text']);
$row['text'] = ereg_replace(":)",$smile, $row['text']);
$row['text'] = ereg_replace(":-)",$smile, $row['text']);
$row['text'] = ereg_replace(":D",$very_happy, $row['text']);
$row['text'] = ereg_replace(":-D",$very_happy, $row['text']);
$row['text'] = ereg_replace(":\(",$nothappy, $row['text']);
$row['text'] = ereg_replace(":-\(",$nothappy, $row['text']);
$row['text'] = ereg_replace(";)",$ironic, $row['text']);
$row['text'] = ereg_replace(";-)",$ironic, $row['text']);
if ($row['ip'] != "") {
$logged = "Yes!";
} else {
$logged = "No";
}
echo "<table cellpadding='2' cellspacing='0' width='100%'><tr><td align='left'>";
$amounts = mysql_query("SELECT * FROM shout WHERE ip = '$row[ip]'");
$entries = mysql_num_rows($amounts);
if ($row['link'] != ""){
echo "<a target='_blank' href='http://$row[link]' title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </a>";
} else {
echo "<b title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </b></a>";
}
echo "$row[text]";
echo "</td></tr></table>";
}
}
?>
<table width="100%" cellpadding="2" cellspacing="0"><tr><td align="center">
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
if ($_COOKIE['name_id_c']){
$name_value = $_COOKIE['name_id_c'];
} else {
$name_value = "Your name";
}
if ($_COOKIE['link_c']){
$link_value = $_COOKIE['link_c'];
} else {
$link_value ="Your link";
}
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
if ($_COOKIE['name_id_c']){
$name_value = $_COOKIE['name_id_c'];
} else {
$name_value = "Your name";
}
if ($_COOKIE['link_c']){
$link_value = $_COOKIE['link_c'];
} else {
$link_value ="Your link";
}
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
</td></tr></table>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
if (isset($_POST['add'])){
if (isset($_POST['link'])){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
if (isset($_POST['add'])){
if (isset($_POST['link'])){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
</body>
if ($_COOKIE['link_c']){
en
if ($name_id_c){
setcookie ("name_id_c", $name_id_c, time()+86400);
}
if ($link_c){
setcookie ("link_c", $link_c, time()+86400);
}
In allen moet nog even isset() gefietst worden, en ook moeten de laatste twee nog even worden omgevormd naar $_COOKIE['naam'].
Notice: Undefined variable: php_self in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 118
De code begint bij line 118:
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
</td></tr></table>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
if (isset($_POST['add'])){
if (isset($_POST['link'])){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
if (isset($_POST['add'])){
if (isset($_POST['link'])){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
</body>
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
kan nog mooier door:
mysql_query("insert into shout (ip,name_id,link,text,time) values ('".$ip."', '".$name_id."', '".$link."', '".$text."', '".$time."')");
echo "<script>location.href='".$_SERVER['PHP_SELF']."?name_id_c=$name_id&link_c=$link';</script>";
$link = trim($link); wordt vandaag $link = trim($_POST['link']);
$name_id = strip_tags($name_id); wordt $name_id = strip_tags($_POST['name_id'], '<a>');
en $text = strip_tags($text, '<a>'); wordt $text = strip_tags($_POST['text'], '<a>');
ER gaat iets mis denk ik in het echo gedeelte:
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
Gewijzigd op 21/09/2005 11:11:00 door nanne
Ook dit is aangepast echter schrijft ie wel de tijd en het ip adres naar de database weg echter niet de naam, tekst en link. Die fout in line 118 blijft in beeld.