﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>PHP博客-AJAX+PHP</title><link>http://www.phpweblog.net/fantasy6/</link><description>选择了远方，便只顾风雨兼程；目标是地平线，留给世界的是如风的背影！</description><language>zh-cn</language><lastBuildDate>Fri, 05 Sep 2008 15:08:28 GMT</lastBuildDate><pubDate>Fri, 05 Sep 2008 15:08:28 GMT</pubDate><ttl>60</ttl><item><title>zde for eclipse 使用笔记2</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3081.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Fri, 28 Mar 2008 16:34:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3081.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/3081.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3081.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/3081.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/3081.html</trackback:ping><description><![CDATA[<p><img src="http://www.phpweblog.net/images/phpweblog_net/fantasy6/2008-03-27_211120.jpg" border=0><br><br><img height=383 src="http://www.phpweblog.net/images/phpweblog_net/fantasy6/2008-03-27_211153.jpg" width=615 border=0><br><br><img src="http://www.phpweblog.net/images/phpweblog_net/fantasy6/2008-03-27_211253.jpg" border=0><br><br><img src="http://www.phpweblog.net/images/phpweblog_net/fantasy6/2008-03-28_142402.jpg" border=0><br><br><br><img src="http://www.phpweblog.net/images/phpweblog_net/fantasy6/aa639.jpg" border=0><br><br></p>
<img src ="http://www.phpweblog.net/fantasy6/aggbug/3081.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fantasy6/" target="_blank">刘伟</a> 2008-03-29 00:34 <a href="http://www.phpweblog.net/fantasy6/archive/2008/03/29/3081.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP作为模板语言的一招！</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3080.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Fri, 28 Mar 2008 16:30:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3080.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/3080.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/29/3080.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/3080.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/3080.html</trackback:ping><description><![CDATA[<p>echo &lt;&lt;&lt;EOT</p>
<p>&lt;div id="mainMenuBar"&gt;&lt;/div&gt;</p>
<p>&lt;link href="scripts/ThemeOffice/theme.css" rel="stylesheet" type="text/css" /&gt;<br>&lt;script language="javascript" type="text/javascript" src="scripts/JSCookMenu.js"&gt;&lt;/script&gt;<br>&lt;script language="javascript" type="text/javascript" src="scripts/ThemeOffice/theme.js"&gt;&lt;/script&gt;</p>
<p>&lt;script language="javascript" type="text/javascript"&gt;<br>{{$output}}</p>
<p>cmDraw ('mainMenuBar', myMenu, 'hbr', cmThemeOffice);<br>&lt;/script&gt;</p>
<p>EOT;</p>
<img src ="http://www.phpweblog.net/fantasy6/aggbug/3080.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fantasy6/" target="_blank">刘伟</a> 2008-03-29 00:30 <a href="http://www.phpweblog.net/fantasy6/archive/2008/03/29/3080.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP正则的应用</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2956.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Wed, 12 Mar 2008 16:02:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2956.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/2956.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2956.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/2956.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/2956.html</trackback:ping><description><![CDATA[1、示例<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">本程序用于接收来自HTML页面的表单数据并进行相应的验证</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">初始化founderr变量，表示没有错误</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #008080">ereg</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">[a-zA-Z_]</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">username</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">]))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">判断姓名格式</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">姓名格式不正确&lt;BR&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #008080">ereg</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">^[0-9]{4}-[0-9]{2}-[0-9]{2}$</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">birthday</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">]))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">判断日期格式</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">日期格式不正确&lt;BR&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #008080">ereg</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">^[a-zA-Z0-9_.]+@([a-zA-Z0-9_]+.)+[a-zA-Z]{2,3}$</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">email</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">]))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">判断E-mail格式.boymumu@yahoo.com.cn</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">E-mail地址格式不正确&lt;BR&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">password</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">password2</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">])&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">判断两次密码是否相等</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">两次密码输入不相同</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #800080">$founderr</span><span style="COLOR: #000000">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">如果没有错误，则输出表单内容</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span></div>
<br>2、常用正则的总结<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">匹配中文字符的正则表达式：&nbsp;[\u4e00</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">\u9fa5]<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：匹配中文还真是个头疼的事，有了这个表达式就好办了<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配双字节字符(包括汉字在内)：[</span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">\x00</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">\xff]<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：可以用来计算字符串的长度（一个双字节字符长度计2，ASCII字符计1）<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配空白行的正则表达式：\n\s</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\r<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：可以用来删除空白行<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配HTML标记的正则表达式：</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">(\S</span><span style="COLOR: #000000">*?</span><span style="COLOR: #000000">)[</span><span style="COLOR: #000000">^&gt;</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">*&gt;.*?|&lt;.*?</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">/&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配首尾空白字符的正则表达式：</span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">\s</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">\s</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">$<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等)，非常有用的表达式<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配Email地址的正则表达式：\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">([</span><span style="COLOR: #000000">-+.</span><span style="COLOR: #000000">]\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">@\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">([</span><span style="COLOR: #000000">-.</span><span style="COLOR: #000000">]\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">([</span><span style="COLOR: #000000">-.</span><span style="COLOR: #000000">]\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：表单验证时很实用<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配网址URL的正则表达式：[a</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">zA</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">z]</span><span style="COLOR: #000000">+:</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">[^\s]*</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配帐号是否合法(字母开头，允许5</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">16字节，允许字母数字下划线)：</span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[a</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">zA</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Z][a</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">zA</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Z0</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9_]{</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">15</span><span style="COLOR: #000000">}$<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配国内电话号码：\d{</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">\d{</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">\d{</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">\d{</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：匹配形式如&nbsp;</span><span style="COLOR: #000000">0511</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">4405222</span><span style="COLOR: #000000">&nbsp;或&nbsp;</span><span style="COLOR: #000000">021</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">87888822</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配腾讯QQ号：[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]{</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：腾讯QQ号从10000开始<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配中国邮政编码：[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d{</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">}(</span><span style="COLOR: #000000">?!</span><span style="COLOR: #000000">\d)&nbsp;&nbsp;&nbsp;&nbsp;\\\中国邮政为6位<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配身份证：\d{</span><span style="COLOR: #000000">15</span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">\d{</span><span style="COLOR: #000000">18</span><span style="COLOR: #000000">}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\\\身份证有15或18位<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配ip地址：\d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配特定数字：<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">$　&nbsp;　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配正整数</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">^-</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">$&nbsp;　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配负整数</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^-?</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">$　　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配整数</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">$　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配非负整数（正整数&nbsp;+&nbsp;0）</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^-</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">$　　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配非正整数（负整数&nbsp;+&nbsp;0）</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">$　　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配正浮点数</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^-</span><span style="COLOR: #000000">([</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">)$　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配负浮点数</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^-?</span><span style="COLOR: #000000">([</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">+|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)$　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配浮点数PHPChina&nbsp;开源社区门户*X*t&nbsp;O&nbsp;F2M-_</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">\d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]\d</span><span style="COLOR: #000000">*|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">+|</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">$　　&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配非负浮点数（正浮点数&nbsp;+&nbsp;0）</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">评注：处理大量数据时有用，具体应用时注意修正<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>匹配特定字符串：<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[A</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Za</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">z]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">$　　</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配由26个英文字母组成的字符串</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[A</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Z]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">$　　</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配由26个英文字母的大写组成的字符串</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[a</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">z]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">$　　</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配由26个英文字母的小写组成的字符串</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">[A</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Za</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">z0</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">$　　</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配由数字和26个英文字母组成的字符串</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">^</span><span style="COLOR: #000000">\w</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">$　　</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">匹配由数字、26个英文字母或者下划线组成的字符串</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>评注：最基本也是最常用的一些表达式<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span></div>
<img src ="http://www.phpweblog.net/fantasy6/aggbug/2956.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fantasy6/" target="_blank">刘伟</a> 2008-03-13 00:02 <a href="http://www.phpweblog.net/fantasy6/archive/2008/03/13/2956.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JQ的Ajax登陆</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2955.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Wed, 12 Mar 2008 16:00:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2955.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/2955.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/13/2955.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/2955.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/2955.html</trackback:ping><description><![CDATA[<p><font style="BACKGROUND-COLOR: #cce8cf">&nbsp;1 、Ajax 登陆<br>（1）login.html<br><br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">html</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">head</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text/javascript"</span><span style="COLOR: #ff0000">&nbsp;src</span><span style="COLOR: #0000ff">="jquery.js"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text/javascript"</span><span style="COLOR: #ff0000">&nbsp;src</span><span style="COLOR: #0000ff">="login.js"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">style&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text/css"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #800000; BACKGROUND-COLOR: #f5f5f5"><br>body&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">{</span><span style="COLOR: #ff0000; BACKGROUND-COLOR: #f5f5f5">&nbsp;font</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">12px/1.6em&nbsp;"宋体"&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">}</span><span style="COLOR: #800000; BACKGROUND-COLOR: #f5f5f5"><br>ul&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">{</span><span style="COLOR: #ff0000; BACKGROUND-COLOR: #f5f5f5">&nbsp;list-style</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">none</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;</span><span style="COLOR: #ff0000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">}</span><span style="COLOR: #800000; BACKGROUND-COLOR: #f5f5f5"><br>li&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">{</span><span style="COLOR: #ff0000; BACKGROUND-COLOR: #f5f5f5">&nbsp;margin-top</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">10px</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;</span><span style="COLOR: #ff0000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">}</span><span style="COLOR: #800000; BACKGROUND-COLOR: #f5f5f5"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">style</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">head</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">body</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">h3</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">会员登录</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">h3</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">div&nbsp;</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="login"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">form&nbsp;</span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="post"</span><span style="COLOR: #ff0000">&nbsp;action</span><span style="COLOR: #0000ff">="login.php"</span><span style="COLOR: #ff0000">&nbsp;id</span><span style="COLOR: #0000ff">="form"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="form"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">ul</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">名字：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user"</span><span style="COLOR: #ff0000">&nbsp;id</span><span style="COLOR: #0000ff">="user"</span><span style="COLOR: #ff0000">&nbsp;size</span><span style="COLOR: #0000ff">="16"</span><span style="COLOR: #ff0000">&nbsp;maxlength</span><span style="COLOR: #0000ff">="20"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">密码：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="password"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="pass"</span><span style="COLOR: #ff0000">&nbsp;id</span><span style="COLOR: #0000ff">="pass"</span><span style="COLOR: #ff0000">&nbsp;size</span><span style="COLOR: #0000ff">="16"</span><span style="COLOR: #ff0000">&nbsp;maxlength</span><span style="COLOR: #0000ff">="20"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="submit"</span><span style="COLOR: #ff0000">&nbsp;style</span><span style="COLOR: #0000ff">="border:0"</span><span style="COLOR: #ff0000">&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">li&nbsp;</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="confirm"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">li</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">ul</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">form</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">div</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">body</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">html</span><span style="COLOR: #0000ff">&gt;</span></div>
</font><br>（2）login.js<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">$(document).ready<br><br>(<br></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#form</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).submit<br>&nbsp;&nbsp;&nbsp;&nbsp;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;login();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;);<br>}<br>);<br></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">&nbsp;login()<br>{<br></span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;user&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#user</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).val();<br></span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;pass&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#pass</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).val();<br></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(user&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#confirm</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).text(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">请输入登录用户名</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">user</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).focus();<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br>}<br></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(pass&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#confirm</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).text(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">请输入登录密码</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#pass</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).focus();<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br>}<br>$.ajax({<br>&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">POST</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br>&nbsp;&nbsp;&nbsp;&nbsp;url:&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">login.php</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,<br>&nbsp;&nbsp;&nbsp;&nbsp;data:&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;user&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&amp;p=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;pass,<br>&nbsp;&nbsp;&nbsp;&nbsp;beforeSend:&nbsp;</span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(){<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">confirm</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).text(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">登录中，请稍候<img src="http://www.phpweblog.net/Images/dot.gif"><img src="http://www.phpweblog.net/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;},<br>&nbsp;&nbsp;&nbsp;&nbsp;success:&nbsp;</span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">(msg){<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(msg&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">success</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#confirm</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).text(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">登录成功，欢迎</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;user&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">回来！正在进入你的空间<img src="http://www.phpweblog.net/Images/dot.gif"><img src="http://www.phpweblog.net/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">#confirm</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">).text(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">没有此用户或者密码不正确！</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>});<br>}<br></span></div>
<br>(3)login.php<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$p</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">isset</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">])&nbsp;</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_GET</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$id</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">isset</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">])&nbsp;</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_GET</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$id</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">admin</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$p</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">admin</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">){<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">success</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span></div>
<img src ="http://www.phpweblog.net/fantasy6/aggbug/2955.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fantasy6/" target="_blank">刘伟</a> 2008-03-13 00:00 <a href="http://www.phpweblog.net/fantasy6/archive/2008/03/13/2955.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP操作目录和文件</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2953.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Wed, 12 Mar 2008 13:52:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2953.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/2953.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2953.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/2953.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/2953.html</trackback:ping><description><![CDATA[1、目录<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">test/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">设置目录为test</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #008080">is_dir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">如果目录存在，则打开</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">$dir_res</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">opendir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">否则输出错误信息</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">目录不存在或者不是一个有效目录</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">closedir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir_res</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">关闭目录</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">files/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">定义路径</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir_res</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">opendir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">打开目录</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$filen</span><span style="COLOR: #000000">=</span><span style="COLOR: #008080">readdir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir_res</span><span style="COLOR: #000000">))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">循环读取目录中的文件</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$filen</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;br&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">closedir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir_res</span><span style="COLOR: #000000">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">关闭目录</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Test/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #008080">is_dir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">如果目录不存在则创建</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008080">mkdir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Test/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #008080">is_dir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">如果目录存在则删除</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008080">rmdir</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>2、文件操作<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)打开和关闭</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">fopen</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">test.txt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">fclose</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)读取</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">fopen</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">test.txt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">r</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">fgetc</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">读取一个字符</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">fgets</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">读取一行</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">fread</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">);&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">读取前20个字符</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">)写入</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">fopen</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">test.txt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">fwrite</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">helloworld\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">写入一行</span><span style="COLOR: #008000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">)删除文件</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">unlink</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">)获取长度</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$size</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">filesize</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$file</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">)复制文件</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir_file1</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">up/file1.txt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$dir_file2</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">up/file1.bak</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">copy</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$dir_file1</span><span style="COLOR: #000000">,</span><span style="COLOR: #800080">$dir_file2</span><span style="COLOR: #000000">);</span></div>
<br>3、文件上传<br><br>file.html<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">form&nbsp;</span><span style="COLOR: #ff0000">enctype</span><span style="COLOR: #0000ff">="multipart/form-data"</span><span style="COLOR: #ff0000">&nbsp;action</span><span style="COLOR: #0000ff">="Upload.php"</span><span style="COLOR: #ff0000">&nbsp;method</span><span style="COLOR: #0000ff">="post"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>　　</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="upfile"</span><span style="COLOR: #ff0000">&nbsp;type</span><span style="COLOR: #0000ff">="file"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">BR</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>　　</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="submit"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="Submit"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">form</span><span style="COLOR: #0000ff">&gt;</span></div>
<br>Upload.php<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$uploadfile</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">upfiles/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_FILES</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">upfile</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #008080">move_uploaded_file</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_FILES</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">upfile</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">tmp_name</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$uploadfile</span><span style="COLOR: #000000">)){<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">sucess!&lt;p&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">{<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">error!</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>}<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">print_r</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$_FILES</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span></div>
<img src ="http://www.phpweblog.net/fantasy6/aggbug/2953.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/fantasy6/" target="_blank">刘伟</a> 2008-03-12 21:52 <a href="http://www.phpweblog.net/fantasy6/archive/2008/03/12/2953.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>最简单的AJAX实现</title><link>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2949.html</link><dc:creator>刘伟</dc:creator><author>刘伟</author><pubDate>Tue, 11 Mar 2008 18:06:00 GMT</pubDate><guid>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2949.html</guid><wfw:comment>http://www.phpweblog.net/fantasy6/comments/2949.html</wfw:comment><comments>http://www.phpweblog.net/fantasy6/archive/2008/03/12/2949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/fantasy6/comments/commentRss/2949.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/fantasy6/services/trackbacks/2949.html</trackback:ping><description><![CDATA[<p>其实呢，准备从今天开始正式复习PHP的基础内容，为下一步的高阶内容做铺垫。。。<br>于是乎在复习的同时准备多动动手，敲敲代码。。。</p>
<p>不敲不知道，真是一敲吓一跳啊！！！手太生了T.T...</p>
<p>不多说了，看看今天都敲了什么东西吧。。。</p>
<p>一、最简单的POST_AJAX：</p>
<p>1.test.html</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;InitAjax()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">try</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Msxml2.XMLHTTP</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">catch</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(e)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">try</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Microsoft.XMLHTTP</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">catch</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(E)&nbsp;{<br>　&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br>　&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">!</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">typeof</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;XMLHttpRequest</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">!=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">'undefined')&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;XMLHttpRequest();<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">return</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax;<br><br>}<br><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;postUserInfo(){<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;msg&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;document.getElementById(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">msg</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;document.user_info;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userName&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_name.value;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userAge&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_age.value;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">f.user_sex.length;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(f.user_sex[i].checked){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userSex&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_sex[i].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;url&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">test.php</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;postStr&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">name=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">userName</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;age=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">userAge</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;sex=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">userSex;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;InitAjax();<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.open(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">POST</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,url,</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">true</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.setRequestHeader(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Content-Type</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">application/x-www-form-urlencoded</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.send(postStr);<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.onreadystatechange&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(ajax.readyState&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">4</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax.status&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">200</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg.innerHTML&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax.responseText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br><br><br>}<br><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">form&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="user_info"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>姓名：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_name"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br>年龄：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_age"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br>性别：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="radio"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_sex"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="男"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">男</span><span style="COLOR: #ff0000">&amp;nbsp;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="radio"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_sex"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="女"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">女</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="button"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="提交"</span><span style="COLOR: #ff0000">&nbsp;onClick</span><span style="COLOR: #0000ff">="postUserInfo()"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">form</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">div&nbsp;</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="msg"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">div</span><span style="COLOR: #0000ff">&gt;</span></div>
<br>2.test.php<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">&lt;?</span><span style="COLOR: #ff00ff">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>header('Content-Type:text/html;charset=utf-8');<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>$name&nbsp;=&nbsp;$_POST['name'];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>$age&nbsp;=&nbsp;$_POST['age'];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>$sex&nbsp;=&nbsp;$_POST['sex'];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top>echo&nbsp;"姓名：".$name."&lt;/br&gt;"."年龄：".$age."&lt;/br&gt;"."性别：".$sex."&lt;/br&gt;";<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>二、用JQ实现同样功能<br><br>1、test.html<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script&nbsp;</span><span style="COLOR: #ff0000">src</span><span style="COLOR: #0000ff">="jquery.js"</span><span style="COLOR: #ff0000">&nbsp;type</span><span style="COLOR: #0000ff">="text/javascript"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text/javascript"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><br><br><br>$(</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(){<br>&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">#postInfo</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">).click(</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(){<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;user_name&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:text</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)[</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;user_age&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:text</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)[</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">1</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:radio</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">).length;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">($(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:radio</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)[i].checked){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;user_sex&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">:radio</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)[i].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.post(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">test.php</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,{name:user_name,age:user_age,sex:user_sex},</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(txt){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">#msg</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">).html(txt);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;});<br>});<br><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br><br><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">body</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">div&nbsp;</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="msg"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">div</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">form&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="user_info"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br>姓名：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_name"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br>年龄：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="text"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_age"</span><span style="COLOR: #0000ff">&gt;&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br>性别：</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="radio"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_sex"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="男"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">男</span><span style="COLOR: #ff0000">&amp;nbsp;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="radio"</span><span style="COLOR: #ff0000">&nbsp;name</span><span style="COLOR: #0000ff">="user_sex"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="女"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">女</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">input&nbsp;</span><span style="COLOR: #ff0000">type</span><span style="COLOR: #0000ff">="button"</span><span style="COLOR: #ff0000">&nbsp;value</span><span style="COLOR: #0000ff">="提交"</span><span style="COLOR: #ff0000">&nbsp;id</span><span style="COLOR: #0000ff">="postInfo"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">form</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">br&nbsp;</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br><br><br></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">body</span><span style="COLOR: #0000ff">&gt;</span></div>
<br>2.test.php<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008080">header</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">Content-Type:text/html;charset=utf-8</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$name</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$age</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">age</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$sex</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$_POST</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">sex</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">];<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">姓名：</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #800080">$name</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;br&nbsp;/&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">年龄：</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #800080">$age</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;br&nbsp;/&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">性别：</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #800080">$sex</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;p&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000"><br><img src="http://www.phpweblog.net/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>三、又封装了一下<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><br><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax;<br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;initAjax(){<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">try</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Msxml2.XMLHTTP</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">catch</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(e)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">try</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Microsoft.XMLHTTP</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">catch</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(E)&nbsp;{<br>　&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br>　&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">!</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">typeof</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;XMLHttpRequest</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">!=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">'undefined')&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ajax&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;XMLHttpRequest();<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>}<br><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;postAjax(url,data){<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.open(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">POST</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,url,</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">true</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.setRequestHeader(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Content-Type</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">application/x-www-form-urlencoded</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.onreadystatechange&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;callBack;<br>&nbsp;&nbsp;&nbsp;&nbsp;ajax.send(data);<br>}<br><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;callBack(){<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(ajax.readyState&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">4</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax.status&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">200</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;msg&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;document.getElementById(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">msg</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg.innerHTML&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ajax.responseText;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br></span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;postUserInfo(){<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;document.user_info;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userName&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_name.value;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userAge&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_age.value;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">f.user_sex.length;i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(f.user_sex[i].checked){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userSex&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;f.user_sex[i].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;url&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">test.php</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;postStr&nbsp