<?php require_once('config.php'); ?>
<?php
header("Content-Type: text/html; charset=utf-8");
error_reporting(E_ALL^E_NOTICE);
$words=$_POST['words'];
$face=$_COOKIE["src"];
$he=$_COOKIE["he"];
setcookie("src", "", time() - 3600);
$name=$_COOKIE["name"];
if($words||$face){
$query="insert into schat(chtime,me,he,words,face)values(now(),'$name','$he','$words','$face')";//插入SQL语句
mysql_query($query,$link_ID); //发送留言到数据库
header("refresh:0; URL='Stalkshow.php'");
}
?>
<html>
<head>
<title>简单的私聊-显示留言页</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--<meta http-equiv="refresh" content="5;url=show.php">-->
</head>
<body>
<?php
//最新发言显示在最下面
$sql="select * from schat WHERE me='".$name."' AND he='".$he."' or me='".$he."' and he='".$name."' order by chtime asc";
$result=mysql_query($sql);
$total=mysql_num_rows($result);
$info=($total/15-1)*15;
if($total<15){
$str="select * from schat WHERE me='".$name."' AND he='".$he."' or me='".$he."' and he='".$name."' order by chtime asc" ; //查询字符串
}else{
$str="select * from schat WHERE me='".$name."' AND he='".$he."' or me='".$he."' and he='".$name."' order by chtime asc limit $info,15" ; //查询字符串
}
$result=mysql_query($str,$link_ID); //送出查询
while($row=mysql_fetch_array($result)){
if($row['me']==$name){
?>
<div id="me">
<li><?php echo $row['chtime'];?></li>
<?php echo $row['me']?>:
<?php echo $row['words'];?>
<?php if(count($row['face'])){
$arr=explode(',',$row['face']);
foreach($arr as $a){
?>
<img src="<?php echo $a;?>">
<?php
}}?>
</div>
<?php }else{?>
<div class="other">
<li><?php echo $row['chtime'];?></li>
<?php echo $he;?>:
<?php echo $row['words'];?>
<?php if(count($row['face'])){
$arr=explode(',',$row['face']);
foreach($arr as $a){
?>
<img src="<?php echo $a;?>">
<?php
}} ?>
</div>
<?php }} ?>
<div id="quit">X</div>
</body>
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="jquery.cookie.js" type="text/javascript"></script>
<script>
$(function(){
var color=$.cookie('color');
var size=$.cookie('size');
if(color=='black'){
$(window.parent.parent.frames["bottomFrame"].document.body).css({"background-color":color,"color":"white","font-size":size});
$('body').css({"background-color":color,"color":"white","font-size":size});
$(window.parent.parent.frames["rightFrame"].document.body).css({"background-color":color,"color":"white","font-size":size});
}
else{
$('body').css({"background-color":color,"font-size":size,"color":"black"});
$(window.parent.parent.frames["bottomFrame"].document.body).css({"background-color":color,"font-size":size,"color":"black"});
$(window.parent.parent.frames["rightFrame"].document.body).css({"background-color":color,"font-size":size,"color":"black"});
}
//清空文本内容
var text=$(window.parent.parent.frames["bottomFrame"].document).find('.input').html('');
//滚动条自动跟随
click_scroll();
function click_scroll() {
var t2= $("#me").siblings("div:last").offset(); //得到pos这个div层的offset,包含两个值,top和left
var t1=$(".other").siblings("div:last").offset();
if(t2==undefined){
$("body,html").animate({
scrollTop:t1.top //让body的scrollTop等于pos的top,就实现了滚动
},0);
}
else{
$("body,html").animate({
scrollTop:t2.top //让body的scrollTop等于pos的top,就实现了滚动
},0);
}
}
});
$('#quit').click(function(){
$(window.parent.parent.frames["rightFrame"].document).find('#sp').show();
$('#main',window.parent.document).attr('src','show.php');
$('#speak',window.parent.document).attr('src','speak.php');
})
</script>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
php+mysql+jquery实现在线聊天
共89个文件
gif:75个
php:8个
js:2个
5星 · 超过95%的资源 需积分: 13 39 下载量 130 浏览量
2017-11-24
17:46:48
上传
评论
收藏 233KB RAR 举报
温馨提示
实现简单的在线群聊和私聊,正常发表情以及更改背景和字体大小
资源推荐
资源详情
资源评论
收起资源包目录
php.rar (89个子文件)
php
speak.php 4KB
Stalk.php 3KB
index.html 455B
face
17.gif 8KB
58.gif 1KB
61.gif 1KB
9.gif 3KB
29.gif 2KB
40.gif 4KB
4.gif 2KB
27.gif 3KB
50.gif 2KB
51.gif 2KB
55.gif 1KB
63.gif 1KB
20.gif 2KB
38.gif 10KB
56.gif 1KB
47.gif 3KB
23.gif 2KB
65.gif 2KB
45.gif 2KB
37.gif 2KB
67.gif 2KB
70.gif 2KB
73.gif 1KB
33.gif 2KB
22.gif 2KB
41.gif 2KB
11.gif 8KB
26.gif 3KB
72.gif 988B
3.gif 2KB
6.gif 3KB
53.gif 1KB
54.gif 1KB
68.gif 3KB
35.gif 1KB
18.gif 8KB
59.gif 1KB
19.gif 2KB
28.gif 5KB
2.gif 2KB
75.gif 654B
64.gif 2KB
7.gif 4KB
34.gif 13KB
5.gif 5KB
36.gif 2KB
14.gif 4KB
30.gif 6KB
49.gif 1KB
12.gif 2KB
10.gif 4KB
1.gif 2KB
13.gif 2KB
60.gif 3KB
71.gif 971B
16.gif 3KB
32.gif 4KB
52.gif 2KB
57.gif 2KB
43.gif 5KB
46.gif 6KB
66.gif 2KB
42.gif 5KB
44.gif 4KB
15.gif 2KB
48.gif 4KB
25.gif 4KB
8.gif 5KB
24.gif 2KB
31.gif 7KB
69.gif 1KB
74.gif 2KB
21.gif 3KB
62.gif 1KB
39.gif 3KB
config.php 480B
show.php 4KB
index.php 1KB
nicklLogin.php 3KB
chat.sql 8KB
jquery.cookie.js 3KB
login.css 1KB
login.php 2KB
Stalkshow.php 4KB
style.css 2KB
jquery-3.2.1.min.js 85KB
共 89 条
- 1
资源评论
- aslyp20122019-05-27还在学习,参考一下
ZhangY1217
- 粉丝: 26
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功