Data wordt niet ingevoegd in de tabel
Ik loop al de gehele dag te kutten om data in de tabel te krijgen van een chat systeem.
dit is mijn chat.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="POST" onsubmit="minichat(document.getElementById('chattext,naam,chatsec,ipadress').value); document.getElementById('chattext,naam,chatsec,ipadress').value = ''; return false;" id="postform">
<table width="100%" border="0">
<tr>
<td width="10%" valign="top">Naam:</td>
<td><input type="text" name="naam" id="naam" maxlength="32" style="background-color:#999;"/></td>
</tr>
<tr>
<td width="10%" valign="top">Bericht:</td>
<td><input class="mytext" id="chattext" type="tekst" name="chat"/></td>
</tr>
</table>
<input type="hidden" name="chatte" id="chatsec" value="chatsec"/>
<input type="hidden" name="ipadrr" id="ipadress" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"/>
<input type="submit" name="submit" value="chatten" style="background-image:url(../images/menu-button2.png); background-repeat:no-repeat; height:28px;" />
</form>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="POST" onsubmit="minichat(document.getElementById('chattext,naam,chatsec,ipadress').value); document.getElementById('chattext,naam,chatsec,ipadress').value = ''; return false;" id="postform">
<table width="100%" border="0">
<tr>
<td width="10%" valign="top">Naam:</td>
<td><input type="text" name="naam" id="naam" maxlength="32" style="background-color:#999;"/></td>
</tr>
<tr>
<td width="10%" valign="top">Bericht:</td>
<td><input class="mytext" id="chattext" type="tekst" name="chat"/></td>
</tr>
</table>
<input type="hidden" name="chatte" id="chatsec" value="chatsec"/>
<input type="hidden" name="ipadrr" id="ipadress" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"/>
<input type="submit" name="submit" value="chatten" style="background-image:url(../images/menu-button2.png); background-repeat:no-repeat; height:28px;" />
</form>
</div>
</body>
</html>
dit is chat1.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
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
75
76
77
78
79
80
81
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
75
76
77
78
79
80
81
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','*****','******','*****');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if(isset($_POST['chatsec']))
{
if($_POST['chat'] == "")
{
$err = "Je hebt geen bericht ingevuld!";
}
elseif($_POST['naam'] == "")
{
$err .= "Je hebt geen naam ingevuld!";
}
else
{
$chat = $_POST['chat'];
$login = $_POST['naam'];
$ip = $_POST['ipadrr'];
$sql_insert = "INSERT INTO chat (id,user,ip,tekst,datum) VALUES (NULL, '".$login."','".$ip."','".$chat."',NOW()";
if(!$res = $mysqli->query($sql_insert))
{
echo 'fout';
}
}
}
}
//Einde data insert
//Begin data output
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 30";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="100%" border="0" style="border-collapse:collapse;">';
//De output
//checken of chat niet leeg is
while($row = $res->fetch_assoc())
{
var_dump($_POST);
echo '
<tr>
<td bgcolor="#999999" class="menuLink" width="20%">'.$row['user'].':</td>
<td bgcolor="#999999" class="menuLink" width="75%">'.makeUBB($row['tekst']).'<br />'.var_dump($_POST).'</td>
</tr>';
}
echo '</table>';
}
//Einde data output
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','*****','******','*****');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if(isset($_POST['chatsec']))
{
if($_POST['chat'] == "")
{
$err = "Je hebt geen bericht ingevuld!";
}
elseif($_POST['naam'] == "")
{
$err .= "Je hebt geen naam ingevuld!";
}
else
{
$chat = $_POST['chat'];
$login = $_POST['naam'];
$ip = $_POST['ipadrr'];
$sql_insert = "INSERT INTO chat (id,user,ip,tekst,datum) VALUES (NULL, '".$login."','".$ip."','".$chat."',NOW()";
if(!$res = $mysqli->query($sql_insert))
{
echo 'fout';
}
}
}
}
//Einde data insert
//Begin data output
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 30";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="100%" border="0" style="border-collapse:collapse;">';
//De output
//checken of chat niet leeg is
while($row = $res->fetch_assoc())
{
var_dump($_POST);
echo '
<tr>
<td bgcolor="#999999" class="menuLink" width="20%">'.$row['user'].':</td>
<td bgcolor="#999999" class="menuLink" width="75%">'.makeUBB($row['tekst']).'<br />'.var_dump($_POST).'</td>
</tr>';
}
echo '</table>';
}
//Einde data output
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
Via var_dump zie ik wel dat ie het doorgeeft.
Maar hij voegt niks toe.
Hoe kan ik het wel goed krijgen.
Met vriendelijke groet Thomas de vries.
Dan kun je ook zien wat er fout gaat.
Tevens is je script onveilig "SQL injection".
Sql injection komt hierna wel
wil eerst die insert goed krijgen.
Je meent toch niet echt dat je het ip adres via een formulier gaat verzenden???
Ik zou eerst eens wat aan je beveiliging gaan doen, want anders gaat het echt niet goedkomen met het script van je...
Waarom zeg je dat het ID NULL moet zijn? Normaal is dit een uniek nummer voor iets dat je in je database hebt opgeslagen?
Gewijzigd op 03/01/2011 16:18:08 door Yea Rupie
hierna gaat het goed en wordt het niet via het form verstuurd.
eerst vragen dan commentaar leveren.
Met id NULL wordt het normaal toegevoegd kan het ook wel weglaten dat is geen probleem
Kan het misschien aan dit liggen firefox geeft namelijk dit aan
Fout: document.getElementById("chattext,naam,chatsec,ipadress") is null
Bronbestand:
Regel: 1
Gewijzigd op 03/01/2011 16:26:42 door thomas de vries
Quote:
document.getElementById("chattext,naam,chatsec,ipadress")
Ja dat ziet me ook erg onlogisch eruit.
Ik heb niet veel verstand van javascript, maar volgens mij moet je alle namen appart tussen "" zetten, want nu vraag je eigenlijk het element met de naam chattext,naam,chatsec,ipadress aan.
EN p.s. verwijder de link van je website. Hij is erg lek en mensen die kwaad willen kunnen verkeerde dingen doen.
Gewijzigd op 03/01/2011 16:24:43 door Yea Rupie
zoals naam en zo.
Doe ik alleen chattext en de rest laat ik weg
dan stuurt ie de data van de naam niet mee.
En als het goed is staat er geen ip adres in je database?
als ik het zonder al die naam en zo doe
en alleen de text doe dan voegt ie ook niks toe.
dus vindt het wel vaag.
Verander name="chatte" in name="chatsec"
Je komt nooit door de isset heen want $_POST['chatsec'] bestaat niet.
if(isset($_POST['chatsec']))
Quote:
@Mark, je was net iets sneller.
Gewijzigd op 03/01/2011 16:40:50 door - SanThe -
Denk dat ik maar effe opnieuw ga beginnen
Kom er effe niet meer uit
Toevoeging op 03/01/2011 17:35:48:
Ke heb nu zo gedaan dat ie wel post in de db maar hij post de
naam niet mee
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;">
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;">
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</body>
</html>
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
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','root','*****','****');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = "test";
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 10";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="50%">';
//De output
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['user'].'">'.$row['user'].':</td>
<td class="menuLink" width="75%">'.makeUBB($row['tekst']).'</td>
</tr>';
}
echo '</table>';
}
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','root','*****','****');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = "test";
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 10";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="50%">';
//De output
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['user'].'">'.$row['user'].':</td>
<td class="menuLink" width="75%">'.makeUBB($row['tekst']).'</td>
</tr>';
}
echo '</table>';
}
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
$login = "test";
Moet ik nu zo doen omdat ie dus de naam niet mee post.
Toevoeging op 03/01/2011 19:04:48:
Zo weet nu waar het aanlicht
maar ben er nog niet uit.
dat ie de naam niet mee zend heeft hier mee te maken
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;">
Want als ik alleen <form method="POST"> doe dan werkt ie wel
onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;"
Je stuurt alleen de tekst en niet de naam
Gewijzigd op 03/01/2011 21:38:39 door Yea Rupie
Ik kan data toevoegen en hij laat het zien.
Maar nu het volgende ik probeer dus
in mijn chat1.php
dit te doen
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo 'Je hebt geen bericht opgegeven.';
}
else
{
$chat = $_POST['text'];
$login = "test";
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
{
if($_POST['text'] == "")
{
echo 'Je hebt geen bericht opgegeven.';
}
else
{
$chat = $_POST['text'];
$login = "test";
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
Dus bij de $_POST['text'] == "")
Je hebt geen bericht opgegeven.
Maar omdat hij dus bij een bepaalde interval de chat1.php laat
laat hij dus ook continue de melding zien van je hebt geen bericht opgegeven.
Hoe krijg ik dit voor elkaar