Dubbelheid van het script
Nu werkt ie helemaal naar behoren.
Maar ik heb toch het gevoel dat ik het dubbel doe.
Kan er iemand naar kijken.
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
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
<?php
session_start();
include ("config.php");
?>
<!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>Untitled Document</title>
<script src="scripts/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:1px;
left:0px;
top:0px;
width:500px;
height:364px;
}
#smilies {
left:0px;
top:364px;
width:500px;
height:31px;
}
#chatten {
left:34px;
top:364px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
}
</style>
</head>
<body>
<div id="chatwindow">
<?php include("chat1.php"); ?>
</div>
<!--Smilies-->
<div id="smilies">
<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>
</div>
<!--chatten-->
<div id="chatten">
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;">
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</html>
</body>
session_start();
include ("config.php");
?>
<!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>Untitled Document</title>
<script src="scripts/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:1px;
left:0px;
top:0px;
width:500px;
height:364px;
}
#smilies {
left:0px;
top:364px;
width:500px;
height:31px;
}
#chatten {
left:34px;
top:364px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
}
</style>
</head>
<body>
<div id="chatwindow">
<?php include("chat1.php"); ?>
</div>
<!--Smilies-->
<div id="smilies">
<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>
</div>
<!--chatten-->
<div id="chatten">
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; return false;">
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</html>
</body>
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
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
<?php
session_start();
include("config.php");
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = $data->login;
$sql_insert = "INSERT INTO chat (id,login,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
echo 'fout';
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 13";
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%">';
//De output
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="4%">';
$sql_online = "SELECT login,online1 FROM users WHERE login = '".$row['login']."'";
if(!$res1 = $mysqli->query($sql_online))
{
echo 'fout';
}
$online = $res1->fetch_assoc();
if($online['online1'] == "1")
{
echo '<img src="/images/icons_gif/status_online.png" title="Online" alt=""/>';
}
else
{
echo '<img src="/images/icons_gif/status_offline.png" title="Offline" alt=""/>';
}
echo '
</td>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['login'].'">'.$row['login'].':</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', 'chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
session_start();
include("config.php");
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = $data->login;
$sql_insert = "INSERT INTO chat (id,login,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
echo 'fout';
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 13";
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%">';
//De output
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="4%">';
$sql_online = "SELECT login,online1 FROM users WHERE login = '".$row['login']."'";
if(!$res1 = $mysqli->query($sql_online))
{
echo 'fout';
}
$online = $res1->fetch_assoc();
if($online['online1'] == "1")
{
echo '<img src="/images/icons_gif/status_online.png" title="Online" alt=""/>';
}
else
{
echo '<img src="/images/icons_gif/status_offline.png" title="Offline" alt=""/>';
}
echo '
</td>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['login'].'">'.$row['login'].':</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', 'chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000);
</script>
Met vriendelijke groet Thomas de vries
Wat denk je dat je dubbel doet?