仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1093|回复: 20
打印 上一主题 下一主题

[学习教程] PHP网页编程之撑持oicq头像的留言簿(二)

[复制链接]
再见西城 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-4 00:05:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
理解动态语言的概念,运做机制,熟悉PHP语法   addnote.php
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>添加留言</TITLE>
<style type="text/CSS">
<!--
.white12 {  font-size: 12pt; color: #FFFFFF; text-decoration: none}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
  <tr>  
    <td height="62" width="34%"><a href="http://www.medguider.com"><img src="http://edu.cnzz.cn/NewsInfo/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
    <td height="62" width="66%">  
      <div align="center"><img src="http://edu.cnzz.cn/NewsInfo/image/note.gif" width="410" height="60"><img src="http://edu.cnzz.cn/NewsInfo/image/y1.gif" width="60" height="60"></div>
    </td>
  </tr>
</table>
<?php
include ("config.php");
if ($submit){
$time=date("Y年m月d日 H:i:s A");
$ip=$REMOTE_ADDR;//留言人ip地址
$name=trim($name);
$email=trim($email);
$title=strip_tags($top);
$nnote=nl2br(strip_tags($content));//先去失落html标志,再将换行符转成 <br>。
if (!$name||!$email||!$title||!$nnote){           //反省是不是填写完全
      echo "对不起,您必需填一切内容!<BR>"."<a href='javascript:history.back()'>前往</a>";
      exit; }elseif(!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+.'.'[-!#$%&'*+\./0-9=?A-Z^_`a-z{|}~]+$',$email)  //email正当性验证
       ){
       echo "email不正当!<BR>"."<a href='javascript:history.back()'>前往</a>";
       exit;
             }
   //写入数据库
$sql="INSERT INTO notebook (name,email,time,face,ip,title,nnote) VALUES ('$name','$email','$time','$face','$ip','$title','$nnote')";
$result = mysql_query($sql,$db);
mysql_close($db);
echo "留言胜利!";
}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#3366FF">
  <tr bgcolor="#3366FF">  
    <td width="81%" class="white12" height="26"><a href="../index.php" class="white12">首页</a>  
      > <a href="index.php" class="white12">留言簿</a>  
      > 添加留言</td>
    <td width="19%" class="white12" height="26"><a href='index.php' class="white12">检查留言</a>  
    </td>
  </tr>
  <tr>  
    <td colspan="2">
      <form name="form1" method="post" action="addnote.php">
        <table width="99%" border="0" cellspacing="0" cellpadding="0">
          <tr>  
            <td width="54%"> </td>
            <td rowspan="2" width="46%">选择一个本人喜好的头像:<br>
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon1.gif" width="32" height="32">  
              <input type="radio" name="face" value="1" checked>
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon2.gif" width="32" height="32">  
              <input type="radio" name="face" value="2">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon3.gif" width="32" height="32">  
              <input type="radio" name="face" value="3">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon4.gif" width="32" height="32">  
              <input type="radio" name="face" value="4">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon5.gif" width="32" height="32">  
              <input type="radio" name="face" value="5">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon6.gif" width="32" height="32">  
              <input type="radio" name="face" value="6">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon7.gif" width="32" height="32">  
              <input type="radio" name="face" value="7">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon8.gif" width="32" height="32">  
              <input type="radio" name="face" value="8">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon9.gif" width="32" height="32">  
              <input type="radio" name="face" value="9">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon10.gif" width="32" height="32">  
              <input type="radio" name="face" value="10">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon11.gif" width="32" height="32">  
              <input type="radio" name="face" value="11">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon12.gif" width="32" height="32">  
              <input type="radio" name="face" value="12">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon13.gif" width="32" height="32">  
              <input type="radio" name="face" value="13">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon14.gif" width="32" height="32">  
              <input type="radio" name="face" value="14">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon15.gif" width="32" height="32">  
              <input type="radio" name="face" value="15">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon16.gif" width="32" height="32">  
              <input type="radio" name="face" value="16">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon17.gif" width="32" height="32">  
              <input type="radio" name="face" value="17">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon18.gif" width="32" height="32">  
              <input type="radio" name="face" value="18">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon19.gif" width="32" height="32">  
              <input type="radio" name="face" value="19">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon20.gif" width="32" height="32">  
              <input type="radio" name="face" value="20">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon21.gif" width="32" height="32">  
              <input type="radio" name="face" value="21">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon22.gif" width="32" height="32">  
              <input type="radio" name="face" value="22">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon23.gif" width="32" height="32">  
              <input type="radio" name="face" value="23">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon24.gif" width="32" height="32">  
              <input type="radio" name="face" value="24">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon25.gif" width="32" height="32">  
              <input type="radio" name="face" value="25">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon26.gif" width="32" height="32">  
              <input type="radio" name="face" value="26">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon27.gif" width="32" height="32">  
              <input type="radio" name="face" value="27">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon28.gif" width="32" height="32">  
              <input type="radio" name="face" value="28">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon29.gif" width="32" height="32">  
              <input type="radio" name="face" value="29">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon30.gif" width="32" height="32">  
              <input type="radio" name="face" value="30">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon31.gif" width="32" height="32">  
              <input type="radio" name="face" value="31">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon32.gif" width="32" height="32">  
              <input type="radio" name="face" value="32">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon33.gif" width="32" height="32">  
              <input type="radio" name="face" value="33">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon34.gif" width="32" height="32">  
              <input type="radio" name="face" value="34">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon35.gif" width="32" height="32">  
              <input type="radio" name="face" value="35">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon36.gif" width="32" height="32">  
              <input type="radio" name="face" value="36">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon37.gif" width="32" height="32">  
              <input type="radio" name="face" value="37">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon38.gif" width="32" height="32">  
              <input type="radio" name="face" value="38">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon39.gif" width="32" height="32">  
              <input type="radio" name="face" value="39">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon40.gif" width="32" height="32">  
              <input type="radio" name="face" value="40">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon41.gif" width="32" height="32">  
              <input type="radio" name="face" value="41">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon42.gif" width="32" height="32">  
              <input type="radio" name="face" value="42">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon43.gif" width="32" height="32">  
              <input type="radio" name="face" value="43">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon44.gif" width="32" height="32">  
              <input type="radio" name="face" value="44">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon45.gif" width="32" height="32">  
              <input type="radio" name="face" value="45">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon46.gif" width="32" height="32">  
              <input type="radio" name="face" value="46">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon47.gif" width="32" height="32">  
              <input type="radio" name="face" value="47">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon48.gif" width="32" height="32">  
              <input type="radio" name="face" value="48">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon49.gif" width="32" height="32">  
              <input type="radio" name="face" value="49">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon50.gif" width="32" height="32">  
              <input type="radio" name="face" value="50">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon51.gif" width="32" height="32">  
              <input type="radio" name="face" value="51">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon52.gif" width="32" height="32">  
              <input type="radio" name="face" value="52">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon53.gif" width="32" height="32">  
              <input type="radio" name="face" value="53">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon54.gif" width="32" height="32">  
              <input type="radio" name="face" value="54">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon55.gif" width="32" height="32">  
              <input type="radio" name="face" value="55">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon56.gif" width="32" height="32">  
              <input type="radio" name="face" value="56">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon57.gif" width="32" height="32">  
              <input type="radio" name="face" value="57">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon58.gif" width="32" height="32">  
              <input type="radio" name="face" value="58">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon59.gif" width="32" height="32">  
              <input type="radio" name="face" value="59">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon60.gif" width="32" height="32">  
              <input type="radio" name="face" value="60">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon61.gif" width="32" height="32">  
              <input type="radio" name="face" value="61">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon62.gif" width="32" height="32">  
              <input type="radio" name="face" value="62">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon63.gif" width="32" height="32">  
              <input type="radio" name="face" value="63">
              <img src="http://edu.cnzz.cn/NewsInfo/image/face/icon64.gif" width="32" height="32">  
              <input type="radio" name="face" value="64">
            </td>
          </tr>
          <tr>  
            <td width="54%">名字  
              <input type="text" name="name">
              <br>
              Email  
              <input type="text" name="email">
              <br>
              题目  
              <input type="text" name="top" size="50">
              <br>
              内容<br>
              <textarea name="content" cols="50" rows="20"></textarea>
            </td>
          </tr>
          <tr>  
            <td colspan="2">  
              <div align="center">
                <input type="submit" name="submit" value="肯定">
                <input type="reset" name="cancel" value="重写">
              </div>
            </td>
          </tr>
        </table>
              </form>
    </td>
  </tr>
</table>
<p><a href="main.php?user=<? echo $user?>" class="white12"><br>
  </a></p>
</BODY>
</HTML>
delnote.php
<?php
include ("config.php");
if ($superadmin){      //假如已停止办理员上岸,停止暗码验证
if (!($user==$username)||!($psw==$password)){  
echo "暗码毛病";
exit;
}
}else{              //办理员上岸
echo "<form name='form1' method='post' action='$PHP_SELF'>";
echo "<div align='center'> 请输出办理员暗码<br>";
echo "办理员";  
echo "<input type='text' name='user'><br>";
echo "暗码";
echo "<input type='password' name='psw'><br>";
echo "<input type='submit' name='superadmin' value='进入'><br>";
echo "<input type='reset' name='cancel' value='重写'></div>";   
echo "</form>";
exit;
}
if($del==1){       //判别是不是要删除
mysql_query("delete from notebook where time='$time'",$db); //以留言工夫为删除标记
echo "删除胜利!";
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>删除留言</TITLE>
<style type="text/css">
<!--
.blue9 {  font-size: 9pt; color: #0099FF; text-decoration: none}
.black9 {  font-size: 9pt; text-decoration: none}
.purple10 {  font-size: 10pt; color: #9900FF; text-decoration: none}
.white12 {  font-size: 12pt; color: #FFFFFF; text-decoration: none}
a:visited {  color: #FFFFFF}
a:link {  color: #FFFFFF}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
$result = mysql_query("SELECT * FROM notebook ",$db);
$row=mysql_num_rows($result);//检查了局有几何行
$max=$row; //帖子总数
//设每页显示10篇,$p总页数,$page第几页,$low 从第几行入手下手读,$x 读取几行
if (!$page){$page=1;}
$p=ceil($max/10);
$low=10*($page-1);
if($page==$p&&($max%10)<>0){$x=($max%10);} else {$x=10;}//假如是最初一页,且不是10的整倍数,读取$max除以10的余数,不然取10
if($max==0){$x=0;}//假如没有帖子,$x取0
$result = mysql_query("select * from notebook ORDER BY time DESC limit $low,$x",$db);
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
  <tr>  
    <td height="62" width="34%"><a href="http://www.medguider.com"><img src="http://edu.cnzz.cn/NewsInfo/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
    <td height="62" width="66%">  
      <div align="center"><img src="http://edu.cnzz.cn/NewsInfo/image/note.gif" width="410" height="60"><img src="http://edu.cnzz.cn/NewsInfo/image/y1.gif" width="60" height="60"></div>
    </td>
  </tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0" height="253" bordercolordark="#FFFFFF" bordercolorlight="#003399" align="center">
  <tr>  
    <td height="250">
      <table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366FF">
        <tr>  
          <td width="28%" class="white12">首页  
            > <a href="index.php" class="white12">留言簿</a></td>
          <td width="56%" class="white12">  
            <?php
          echo "帖子总数:  ",$max,"   第";
          for ($n=1;$n<=$p;$n++){
          echo "<a href=index.php?page=$n>$n</a> ";
          }
          echo "页";
          ?>
          </td>
          <td width="16%"><a href="index.php" class="white12">检查留言</a></td>
        </tr>
      </table>  
<?php
   for ($i=0;$i<=($x-1);$i++) {
   $email=mysql_result($result,$i,'email');
   $face=mysql_result($result,$i,'face');
   $face='image/face/icon'.$face;
   $name=mysql_result($result,$i,'name');
   $time=mysql_result($result,$i,'time');
   $ip=mysql_result($result,$i,'ip');
   $title=mysql_result($result,$i,'title');
   $nnote=mysql_result($result,$i,'nnote');
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' height=107' bordercolor='#FFFFFF'> <tr bgcolor='#eeeeee'>";  
echo "<td width='10%' height='33' bgcolor='#eeeeee' class='blue9'> <img src='http://edu.cnzz.cn/NewsInfo/$face.gif' width='32' height='32'></td>";
echo        "<td width='16%' height='33' bgcolor='#eeeeee' class='blue9'>留言人:$name</td>";
echo        "<td width='41%' height='33' bgcolor='#eeeeee' class='blue9'>宣布于:$time</td>";
echo        "<td width='12%' height='33' bgcolor='#eeeeee' class='blue9'><a href='mailto:$email'><img src='http://edu.cnzz.cn/NewsInfo/image/email.gif' width='16' height='16' border=0></a></td>";
echo        "<td width='21%' height='33' class='blue9'><img src='http://edu.cnzz.cn/NewsInfo/image/ip.gif' width='13' height='15'>  $ip <a href='$PHP_SELF?del=1&time=$time&superadmin=$superadmin&user=$user&psw=$psw'><img src='http://edu.cnzz.cn/NewsInfo/image/del.gif' width='16' height='16' border=0></a></td>  </tr> <tr>";  
echo        "<td colspan='5' class='purple10' height='33'>题目:$title</td> </tr>";
echo        "<tr bgcolor='#ffffff'><td colspan='5' class='black9' height='37'>留言内容:$nnote</td></tr></table>";
}
mysql_close($db);
?>     
    </td>
</tr>
</table>
</BODY>
</HTML>
看看西,人家这个编论坛,那个CMS,还有那啥CRM,我啥时候写一个呢?
小魔女 该用户已被删除
沙发
发表于 2015-2-4 08:48:37 | 只看该作者
对于初学者来说不推荐去拿钱买的。当然如果一个网站你经常去用,而且里面的资料也比较有用,最好还是买个会员比较好,毕竟那些也是别人的工作成果。
第二个灵魂 该用户已被删除
板凳
发表于 2015-2-9 20:39:17 | 只看该作者
如果你可以写完像留言板这样的程序,那么你可以去一些别人的代码了,
变相怪杰 该用户已被删除
地板
发表于 2015-2-16 07:53:57 | 只看该作者
兴趣是最好的老师,百度是最好的词典。
老尸 该用户已被删除
5#
发表于 2015-3-5 02:00:25 | 只看该作者
小鸟是第一次发帖(我习惯潜水的(*^__^*) 嘻嘻……),有错误之处还请大家批评指正,另外,前些日子听人说有高手能用php写驱动程序,真是学无止境,人外有人,天外有天。
深爱那片海 该用户已被删除
6#
发表于 2015-3-10 22:49:19 | 只看该作者
写js我最烦的就是 ie 和 firefox下同样的代码 结果显示的结果千差万别,还是就是最好不要用遨游去调试,因为有时候遨游是禁用js的,有可能代码是争取结果被遨游折腾的认为是代码写错。
再现理想 该用户已被删除
7#
发表于 2015-3-17 12:08:22 | 只看该作者
如果你已经到这种程度了,那么你已经可以做我的老师了。其实php也分很多的区域,
冷月葬花魂 该用户已被删除
8#
发表于 2015-3-17 22:09:36 | 只看该作者
你很难利用原理去编写自己的代码。对于php来说,系统的学习我认为还是很重要的,当你有一定理解后,你可你针对某种效果研究,我想那时你不会只是复制代码的水平了。
蒙在股里 该用户已被删除
9#
发表于 2015-3-22 00:42:33 | 只看该作者
使用zendstdio 写代码的的时候,把tab 的缩进设置成4个空格是很有必要的
因胸联盟 该用户已被删除
10#
发表于 2015-3-26 13:32:03 | 只看该作者
本文当是我的笔记啦,遇到的问题随时填充
爱飞 该用户已被删除
11#
发表于 2015-4-14 16:41:36 | 只看该作者
遇到出错的时候,我经常把错误信息直接复制到 google的搜索栏,一般情况都是能搜到结果的,不过有时候会搜出来一大片英文的出来,这时候就得过滤一下,吧中文的弄出来,挨着式方法。
柔情似水 该用户已被删除
12#
发表于 2015-4-15 08:37:27 | 只看该作者
建议加几个专业的phper的群,当然啦需要说话的人多,一处一点问题能有人回答你的,当然啦要让人回答你的问题,平时就得躲在里面聊天,大家混熟啦,愿意回答你问题的人自然就多啦。
精灵巫婆 该用户已被删除
13#
发表于 2015-4-16 16:36:29 | 只看该作者
当然这种网站的会员费就几十块钱。
愤怒的大鸟 该用户已被删除
14#
发表于 2015-4-19 04:25:18 | 只看该作者
刚开始安装php的时候,我图了个省事,把php的扩展全都打开啦(就是把php.ini 那一片 extension 前面的冒号全去掉啦),这样自然有好处,以后不用再需要什么功能再来打开。
飘灵儿 该用户已被删除
15#
发表于 2015-4-24 07:54:25 | 只看该作者
做为1门年轻的语言,php一直很努力。
简单生活 该用户已被删除
16#
发表于 2015-5-4 09:34:49 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
山那边是海 该用户已被删除
17#
发表于 2015-5-8 07:10:35 | 只看该作者
这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。
莫相离 该用户已被删除
18#
发表于 2015-5-12 05:03:44 | 只看该作者
这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。
再见西城 该用户已被删除
19#
 楼主| 发表于 2015-5-12 05:53:38 | 只看该作者
首推的搜索引擎当然是Google大神,其次我比较喜欢 百度知道。不过搜出来的结果往往都是 大家copy来copy去的,运气的的概率很大。
乐观 该用户已被删除
20#
发表于 2015-6-10 18:21:45 | 只看该作者
其实也不算什么什么心得,在各位大侠算是小巫见大巫了吧,望大家不要见笑,若其中有错误的地方请各位大虾斧正。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-29 08:55

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表