用PHP发送MIME邮件
时间:2007-02-17 来源:PHP爱好者
PHP & Javascript控制系列:客户端数据存储(三)<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
作者/来源:limodou <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
PHP & Javascript控制系列:客户端数据存储(三)<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
作者:Luis Argerich, Alejandro Mitrou 译者:limodou<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
Ok, 然后是用于测试目的“form”帧:<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
--------------------------------------------------------------------------------<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
session_start(); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if (!isset($timestamp)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$timestamp=0; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 显示表单,使用Javascript来得到最后的时间戳<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if (isset($msg)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$dab=mysql_connect("localhost", "root", "seldon"); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
mysql_select_db("testbase",$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$query= "insert into testeable(timestamp,message) values(now(),'$msg')"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
mysql_query($query,$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 现在得到在last_time之后的所有聊天对话<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$query= "select * from testeable where timestamp>'$tt'"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$result=mysql_query($query,$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$msgs=array();$i=0;$timestamp=0; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
while($res=mysql_fetch_array($result)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$msgs[]=$res["message"]; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if($res["timestamp"]>$timestamp) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$tt=$res["timestamp"]; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
session_register("timestamp"); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 现在我有了最大的时间戳,使用Javascript,我们可以设置这些值 ?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<script> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
for($i=0;$i<$count($msgs);$i++) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
top.lines[top.lines.length]="<?print("$msgs[$i]");?>"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
top.display.location.reload(); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
</script> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<form name="foo" action=" <?php print("$PHP_SELF"); ?>" method="post"> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
Message:<input type="text" name="msg"> <input type="submit" name="newmsg" value="send"> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
</form>--------------------------------------------------------------------------------<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
注意,我们根据"form"帧来刷新显示,这对用户很好,因为一旦他提交了他的信息就会被马上看见。用户喜欢这样,因为它在聊天室中增加了一些动态机制。你也看到了,form帧与装入帧非常象。 <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
我们向你展示了一个极为有用的技术,它通过将数据保存在客户端从而减少了c/s间的传输量,并且在客户执行一个复杂的显示操作时减少了从服务器的信息装入。现在你有了能力,去征服世界吧! <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
非常全面的一个php技术网站,php爱好者站 http://www.phpfans.net 有相当丰富的文章和源代码.
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
作者/来源:limodou <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
PHP & Javascript控制系列:客户端数据存储(三)<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
作者:Luis Argerich, Alejandro Mitrou 译者:limodou<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
Ok, 然后是用于测试目的“form”帧:<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
--------------------------------------------------------------------------------<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
session_start(); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if (!isset($timestamp)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$timestamp=0; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 显示表单,使用Javascript来得到最后的时间戳<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if (isset($msg)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$dab=mysql_connect("localhost", "root", "seldon"); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
mysql_select_db("testbase",$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$query= "insert into testeable(timestamp,message) values(now(),'$msg')"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
mysql_query($query,$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 现在得到在last_time之后的所有聊天对话<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$query= "select * from testeable where timestamp>'$tt'"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$result=mysql_query($query,$dab); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$msgs=array();$i=0;$timestamp=0; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
while($res=mysql_fetch_array($result)) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$msgs[]=$res["message"]; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
if($res["timestamp"]>$timestamp) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
$tt=$res["timestamp"]; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
session_register("timestamp"); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
// 现在我有了最大的时间戳,使用Javascript,我们可以设置这些值 ?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<script> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
for($i=0;$i<$count($msgs);$i++) { <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
top.lines[top.lines.length]="<?print("$msgs[$i]");?>"; <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
top.display.location.reload(); <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
</script> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<?php <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
} <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
?> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<form name="foo" action=" <?php print("$PHP_SELF"); ?>" method="post"> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
Message:<input type="text" name="msg"> <input type="submit" name="newmsg" value="send"> <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
</form>--------------------------------------------------------------------------------<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
注意,我们根据"form"帧来刷新显示,这对用户很好,因为一旦他提交了他的信息就会被马上看见。用户喜欢这样,因为它在聊天室中增加了一些动态机制。你也看到了,form帧与装入帧非常象。 <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
<br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
我们向你展示了一个极为有用的技术,它通过将数据保存在客户端从而减少了c/s间的传输量,并且在客户执行一个复杂的显示操作时减少了从服务器的信息装入。现在你有了能力,去征服世界吧! <br>
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
wwww.chin aitpower.comRTnIMdrn50BYmHhR9IVa8Io3q
非常全面的一个php技术网站,php爱好者站 http://www.phpfans.net 有相当丰富的文章和源代码.
相关阅读 更多 +