当前位置:  编程技术>php
本页文章导读:
    ▪基于文本的留言簿       固然基数据库的留言簿可以作得很漂亮,而且也更好管理。 但是对于那些没有数据库空间的朋友们来说,基于文本的留言簿也完成可以适用于个人站来使用。而且只要我们努力去做同样可.........
    ▪图书管理程序(一)       本级程序所用的数据表结构: # -------------------------------------------------------- # # 数据表的结构 'author' # CREATE TABLE author (    author_id int(6) DEFAULT '0' NOT NULL auto_increment,    first_name varchar(20) binar.........
    ▪图书管理程序(二)       图书目录输入部分: <? if(!$UploadAction): ?> <? //本程序是为输入书名,作者、出版社资料而设。 //编者:孔秀祥。日期:2001/3/24 /* session_start(); if (!isset($auth_passed)) { echo "本功能只有授权.........

[1]基于文本的留言簿
    来源: 互联网  发布时间: 2013-11-30
固然基数据库的留言簿可以作得很漂亮,而且也更好管理。 但是对于那些没有数据库空间的朋友们来说,基于文本的留言簿也完成可以适用于个人站来使用。而且只要我们努力去做同样可以做得很好,甚至可以说丝毫不比基于数据库的留言簿差。在这里我向介绍一个基于文本的留言簿。在下面这个地址你可以看到它的演示:http://bamboo.oso.com.cn/note.htm,它具有以下两个特点:
1.    用不同的颜我显示不同人发表的留言;
2.    每个留言者具有选择小图标的功能。
本留言簿要由以下四个文件组成:记录留言内容的note.txt文件;记录留言文字显示颜色的color.txt文件;这两个文件都可以有notepad来创建。反应留言表单的note.htm文件;最终处理留言信息的note.php文件。以下是它们的源代码:
note.htm:
<html>
<head>
<title>===留言簿===</title>
</head>
<body>
  <form method="POST" action="/blog_article/note.html">       
          你的大名:<input type="text" name="name" size="44"><br>       
          你的邮件地址:<input type="text" name="email" size="40"><br>       
          你的个人主页:<input type="text" name="webname" size="40"><br>       
          你的个人主页地址:<input type="text" name="webadd" size="35"><br>       
          你的留言:<br>       
                          
    <textarea rows="2" name="note" cols="50"></textarea>        
      请选择你喜欢的图标:        
       <input type="radio" value="1" checked name="icon">  <img border="0" src="/blog_article/n1.gif" width="19" height="18">         
    <input type="radio" name="icon" value="2">  <img border="0" src="/blog_article/n2.gif" width="16" height="16">      
    <input type="radio" name="icon" value="3">  <img border="0" src="/blog_article/n3.gif" width="16" height="16">     
    <input type="radio" name="icon" value="4">  <img border="0" src="/blog_article/n4.gif" width="19" height="18">       
    <input type="radio" name="icon" value="5">  <img border="0" src="/blog_article/n5.gif" width="19" height="18">       
    <input type="radio" name="icon" value="6">   <img border="0" src="/blog_article/n6.gif" width="19" height="18">      
    <input type="radio" name="icon" value="7">   <img border="0" src="/blog_article/n7.gif" width="15" height="15">       
    <input type="radio" name="icon" value="8">   <img border="0" src="/blog_article/n8.gif" width="19" height="18">        
       <input type="radio" name="icon" value="9">  <img border="0" src="/blog_article/n9.gif" width="19" height="18">         
    <input type="radio" name="icon" value="10">  <img border="0" src="/blog_article/n10.gif" width="18" height="18">     
    <input type="radio" name="icon" value="11">  <img border="0" src="/blog_article/n11.gif" width="18" height="18">     
    <input type="radio" name="icon" value="12">  <img border="0" src="/blog_article/n12.gif" width="18" height="18">       
    <input type="radio" name="icon" value="13">  <img border="0" src="/blog_article/n13.gif" width="15" height="15">        
    <input type="radio" name="icon" value="14">   <img border="0" src="/blog_article/n14.gif" width="18" height="18">      
    <input type="radio" name="icon" value="15">    <img border="0" src="/blog_article/n15.gif" width="15" height="15">               
    </div>     
  <div align="left">      
            
    <input type="submit" value="发送" name="B1"><input type="reset" value="重写" name="B2">       
    <a href="/blog_article/note/primsg/1.html">查看留言</a><br>      
    </div>     
  </form>      
  </body>                   
</html>                   
其中:nx.gif是小图标图片,你自己可以更换。
Note.php:
<?
    if($primsg==1){
       $f = fopen("note.txt","r");
       $msg = fread($f,filesize("note.txt"));
       fclose($f);
       print "$msg";  }
    else{
          if ($name=="") {
            print "你总得给我留下的你的大名吧!否则我如何称呼你?<br>";}
            else if  ($note=="") {
            print "你总得说点什么吧?否则点发送干什么?不会是点错了吧?想查看留言??<br>";
              }
          else{
             if  ($email=="") {
            print "连电子邮件地址也不给留?我如何跟你联系?<br>";
                }
             else if  ($webname==""||$webadd="") {
             print "你没有个人主页?如果有还是希望你给我留下的地址,当作是宣传也可以嘛!<br>";
                }
              $t = date(Y年m月d日);
              $note = str_replace ( "<",  "<", $note);
              $note = str_replace ( ">",  ">", $note);
              $note = str_replace ( "\n",  "<br>", $note);
              $f = fopen("color.txt","r+");
              $color1=fread($f,filesize("color.txt"));
              if($color1==0){
                $color=ff0000;}
              else if($color1==1){
                $color="0000ff";}
              else if($color1==2){
                $color="00ff00";
              }
              else if($color1==3){
                $color="000000";
              }
              if($color1>=3){
                 $color1=0;}
              else{
                 $color1+=1;
              }
              fseek($f,0);
              fputs($f,$color1);
              fclose($f);
              for($I=1;$I<=15;$I++){
                 if($I==$icon){
                   $pic=$I;
                   }
                 }
              $str=strval($pic);
              $strhtml="<img src='/blog_article/n/index.html".$str.".gif'>";
              $add="<a href="/blog_article/.$webadd"></a>";
              $main = "$strhtml<br><font color=$color><a href=/index.html"mailto:$email\">$name</a>&nbsp&nbsp&nbsp&nbsp个人主页:&nbsp$add$webname</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp($t)<br>
              说:$note <br>";
              $f = fopen("note.txt","a");
              fwrite($f,$main);
              fclose($f);
               $f = fopen("note.txt","r");
              $msg = fread($f,filesize("note.txt"));
              fclose($f);
               echo"$msg";
              }
}
?>

    
[2]图书管理程序(一)
    来源: 互联网  发布时间: 2013-11-30
本级程序所用的数据表结构:
# --------------------------------------------------------
#
# 数据表的结构 'author'
#

CREATE TABLE author (
   author_id int(6) DEFAULT '0' NOT NULL auto_increment,
   first_name varchar(20) binary NOT NULL,
   last_name varchar(20) NOT NULL,
   address varchar(100) binary NOT NULL,
   zipcode varchar(10) NOT NULL,
   telephone varchar(10) NOT NULL,
   email varchar(50) NOT NULL,
   comment varchar(255) NOT NULL,
   PRIMARY KEY (author_id),
   KEY first_name (first_name),
   KEY last_name (last_name),
   KEY address (address),
   KEY zipcode (zipcode),
   KEY email (email)
);

# --------------------------------------------------------
#
# 数据表的结构 'books'
#

CREATE TABLE books (
   books_id int(6) DEFAULT '0' NOT NULL auto_increment,
   books_name varchar(100) binary NOT NULL,
   publisher_id varchar(6) NOT NULL,
   date_pub datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
   type varchar(6) NOT NULL,
   pages varchar(4) NOT NULL,
   price float(6,2) DEFAULT '0.00' NOT NULL,
   comment varchar(255) binary NOT NULL,
   ISBN varchar(25) NOT NULL,
   PRIMARY KEY (books_id),
   KEY name (books_name),
   KEY publisher (publisher_id),
   KEY date_pub (date_pub),
   KEY price (price),
   KEY pages (pages),
   KEY type (type),
   KEY ISBN (ISBN)
);
# --------------------------------------------------------
#
# 数据表的结构 'books_author'
#

CREATE TABLE books_author (
   id int(6) DEFAULT '0' NOT NULL auto_increment,
   books_id varchar(6) NOT NULL,
   author_id varchar(6) NOT NULL,
   author_type varchar(6) NOT NULL,
   PRIMARY KEY (id)
);

# --------------------------------------------------------
#
# 数据表的结构 'publisher'
#

CREATE TABLE publisher (
   publisher_id int(6) DEFAULT '0' NOT NULL auto_increment,
   publisher_name varchar(100) binary NOT NULL,
   address varchar(100) NOT NULL,
   zipcode varchar(10) NOT NULL,
   telephone varchar(10) NOT NULL,
   telefax varchar(10) NOT NULL,
   email varchar(50) NOT NULL,
   PRIMARY KEY (publisher_id),
   KEY name (publisher_name),
   KEY address (address),
   KEY email (email)
);


    
[3]图书管理程序(二)
    来源: 互联网  发布时间: 2013-11-30
图书目录输入部分:
<?
if(!$UploadAction):
?>
<?
//本程序是为输入书名,作者、出版社资料而设。
//编者:孔秀祥。日期:2001/3/24
/*
session_start();
if (!isset($auth_passed)) {
echo "本功能只有授权用户才能使用。";
return -1;
}

if(isset($u_name)) {
  session_name($u_name);

//echo "<center><font color='red'>".session_name().":本程序将竭诚为您服务。</font></center>\n";
//echo "<hr>";
}
*/
?>
<HTML><HEAD>
<TITLE>图书目录输入 </TITLE>
</HEAD>
<BODY><TABLE align=CENTER>
<FORM ENCTYPE= "multipart/form-data" NAME = "SubmitForm"
ACTION= "<? $PHP_SELF ?>" METHOD = "POST">
<INPUT TYPE= "hidden" NAME = "MAX_FILE_SIZE" VALUE ="20000000">
<INPUT TYPE= "hidden" NAME = "UploadAction" VALUE = "1">

<!--TR><TD>文件名<TD><INPUT NAME = "UploadFile" TYPE = "file" VALUE="" SIZE = "30"></TR-->
<TR><TD align=center>著作名<TD><INPUT NAME = "b_name" TYPE = "text" VALUE="" SIZE = "30" maxlength=100></TD></TR>
<TR><TD align=center>作者<TD>姓<INPUT NAME = "a_first1" TYPE = "text" VALUE="" SIZE = "6" maxlength=20>
名<INPUT NAME = "a_last1" TYPE = "text" VALUE="" SIZE = "6" maxlength=20></TD></TR>
<TR><TD align=center>作者<TD>姓<INPUT NAME = "a_first2" TYPE = "text" VALUE="" SIZE = "6" maxlength=20>
名<INPUT NAME = "a_last2" TYPE = "text" VALUE="" SIZE = "6" maxlength=20></TD></TR>
<TR><TD align=center>作者<TD>姓<INPUT NAME = "a_first3" TYPE = "text" VALUE="" SIZE = "6" maxlength=20>
名<INPUT NAME = "a_last3" TYPE = "text" VALUE="" SIZE = "6" maxlength=20></TD></TR>
<TD>编著方式</TD>
<TD>
<SELECT size="1" name="author_type" TYPE = "int" default=11>
<OPTION selected value="11">  著 </OPTION>
<OPTION selected value="12"> 编著 </OPTION>
<OPTION value="13"> 主编</OPTION>
<OPTION value="14">副主编</OPTION>
<OPTION value="15">  参编</OPTION>
<OPTION value="16">   注 </OPTION>
<OPTION value="17">   编 </OPTION>
<OPTION value="18">   选 </OPTION>
<OPTION value="19">   评 </OPTION>
<OPTION value="20"> 其他</OPTION>
</SELECT>
  定价<INPUT NAME = "b_price_a" TYPE = "text" VALUE="" SIZE = "3">.<INPUT NAME = "b_price_b" TYPE = "text" VALUE="" SIZE = "2">元
</TR>

<TR><TD align=center>出版社<TD><INPUT NAME = "p_name" TYPE = "text" VALUE="" SIZE = "30" maxlength=100></TD></TR>
<TR><TD>出版日期<TD><INPUT NAME = "p_year" TYPE = "text" VALUE="" SIZE = "4">年
<INPUT NAME = "p_month" TYPE = "text" VALUE="" SIZE = "2">月  
<TR><TD>ISBN<TD><INPUT NAME = "isbn" TYPE = "text" VALUE="" SIZE = "25">

<TR><TD rowspan=5>有关书的说明</TD>
<!--/TR><TR-->
<TD rowspan=5><TEXTAREA wrap=on rows="5" cols="30" NAME = "b_comment" SIZE = "255">
</TEXTAREA></TD>
</TR>
</TABLE>

<TABLE align=center>
<TR><TD align=center>
<INPUT NAME = "submit" VALUE = "提交" TYPE = "submit">
<TD><INPUT NAME = "reset" VALUE = "重置" TYPE = "reset">
</TD></TR>
</FORM></CENTER></TABLE></BODY>

</HTML>

<?

else:
session_start();
require "config.php3";

$b_price=trim($b_price_a)."\.".trim($b_price_b);
if(strlen($p_month)==1)
     $p_month="0".trim($p_month);
if($p_month=="")
    $p_month="01";
$date_pub=trim($p_year)."-".trim($p_month)."-01";

$UploadAction=0;
$repeat=0;      //是不是重复了。
$TimeLimit=0; //设置超时限制时间缺省时间为 30秒设置为0时为不限时
set_time_limit($TimeLimit);
@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能连接数据库!");
@mysql_select_db("$dbname") or die("不能选择数据库!");
//$q="select books.books_id, books.books_name,author.first_name,author.last_name,publisher.publisher_name from books,author,books_author,publisher where books.books_name=\"$b_name\" and books.publisher_id=publisher.publisher_id and books.books_id=books_author.books_id and books_author.author_id=author.author_id";

$b_name=trim($b_name);
$sele="select books.books_id, books.books_name,author.first_name,author.last_name,publisher.publisher_name,books.ISBN,books.price,books.date_pub,books.pages";
$fro=" from books,author,books_author,publisher ";
if(trim($isbn)!="")
    $whe="where books.ISBN=\"$isbn\" ";
elseif(trim($a_first1)!="" && trim($a_last1)!="" && trim($p_name)!="")
    $whe=" where books.books_name=\"$b_name\" and books.publisher_id=publisher.publisher_id and books.books_id=books_author.books_id and books_author.author_id=author.author_id";
else{
    $msg="书名为必填,其他如果ISBN为空,则作者的姓、名,出版社为必填。<BR>请检查是否符合要求。";
    xueroom_error_exit($msg,$PHP_SELF);

}
$q="$sele$fro$whe";

/*
books.books_id,  
books.books_name,
author.first_name,
author.last_name,
publisher.publisher_name
books.ISBN,
books.price,
books.date_pub,
books.pages
*/
$r = @mysql_query($q);
//             $count=@mysql_fetch_row($r);
//             echo "书名".$count[1]."<BR>";
if(!$r){
    echo "查询无效 <BR>";
    exit;
}
if(mysql_num_rows($r)){
    if(trim($isbn)!=""){
        echo "数据重复。<BR>";
        exit;
    }
    else
while($count=mysql_fetch_array($r)){  
/*
          echo "while。<BR>";
          echo trim($a_first1);
          echo trim($count[2]);
          echo trim($a_first1)==trim($count[2]);
          echo "<BR>";
          echo trim($a_last1)==trim($count[3]);
          echo "<BR>";
          echo trim($p_name)==trim($count[4]);
          echo "<BR>";
          */
    if( trim($a_first1)==trim($count[2]) && trim($a_last1)==trim($count[3]) && trim($p_name)==trim($count[4])){
        $data_exist+=1;
        $books_id=$count[0];
        $books_name=$count[1];     
        $first_name=$count[2];
        $last_name=$count[3];
        $repeat=1;
        echo "本书已经在数据库中。<BR>";     
        echo "<font color='red'>书名:</font>".$books_name;
        echo "<BR><font color='blue'>作者:</font>".$first_name.$last_name;
        echo "<BR><font color='red'>国标标准书号:</font>".$count[5];
        echo "<BR><font color='blue'>书价:</font>".$count[6]."元";
        echo "<BR><font color='red'>出版日期:</font>".substr($count[7],0,4)."年".substr($count[7],5,2)."月";
        if($count[8])
          echo "<font color='blue'>页码:</font>".$count[8]."页";
        echo"<BR><A HREF = $PHP_SELF>返回 </A>";
        //$repeat=0;
        exit;
//        break;
    }
}//while($count=mysql_fetch_array($r)){  
}//if(mysql_num_rows($r){


//if(!$repeat){

if($p_name!=""){
    $p_name=trim($p_name);
    $address=trim($address);
    $zipcode=trim($zipcode);
    $telephone=trim($telephone);
    $telefax=trim($telefax);
    $email=trim($email);
    $s_publisher="select publisher_id from publisher where publisher_name=\"$p_name\"";
       $results1 = @mysql_query($s_publisher);
       $count1=mysql_fetch_array($results1);
       if(mysql_num_rows($results1)<1){
          $q_publisher="INSERT INTO publisher (publisher_name, address, zipcode, telephone, telefax, email) VALUES (\"$p_name\", \"$address\", \"$zipcode\", \"$telephone\", \"$telefax\", \"$email\")";
        $result2 = @mysql_query($q_publisher);
        if($result2){
                   $publisher_id= mysql_insert_id();
          }
    }
    else
        $publisher_id= $count1[0];
}

if($b_name==""){
    echo"书名不能为空。";
    exit;
}
else{
    $b_name=trim($b_name);
    $publisher_id=trim($publisher_id);
//    $date_pub=trim($date_pub);
    $type=trim($type);
    $pages=trim($pages);
//    $b_price=trim();
    $isbn=trim($isbn);
    $s_books="select books_id from books where books_name=\"$b_name\" ";
    $results3 = @mysql_query($s_books);
    $count3=mysql_fetch_array($results3);
    if(mysql_num_rows($results3)<1){
        $q_books="INSERT INTO books (books_name, publisher_id, date_pub, type, pages, price,ISBN) VALUES (\"$b_name\", \"$publisher_id\", \"$date_pub\", \"$type\", \"$pages\", \"$b_price\",\"$isbn\")";       
        $result3 = @mysql_query($q_books);
        if($result3){
            $books_id= mysql_insert_id();
        }
    }
    else
        $books_id=$count3[0];
}

if(($a_first1=="")||($a_last1=="")){
    echo"第一作者的姓名不能为空。";
    //exit;
}
else{
    $a_first1=trim($a_first1);
    $a_last1=trim($a_last1);
    $address=trim($address);
    $zipcode=trim($zipcode);
    $telephone=trim($telephone);
    $email=trim($email);
       $s_author="select author_id from author where first_name=\"$a_first1\" and last_name=\"$a_last1\"";
       $results = @mysql_query($s_author);
       $count2=mysql_fetch_array($results);
       if(mysql_num_rows($results)<1){
        $q_author="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first1\", \"$a_last1\", \"$address\",  \"$zipcode\", \"$telephone\", \"$email\")";
        $result1 = @mysql_query($q_author);
        if($result1){
                   $author_id= mysql_insert_id();
          }
    }
    else
        $author_id =$count2[0];

    if($books_id!=""||$author_id!=""){
           $s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
           $resulta = @mysql_query($s_ba);
           //$counta=mysql_fetch_array($resulta);
           if(mysql_num_rows($resulta)<1){
            $q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
            $author_id="";
            $resulta = @mysql_query($q_books_author);
        }
    }
}
if(($a_first2!="")||($a_last2!="")){
    $a_first2=trim($a_first2);
    $a_last2=trim($a_last2);
       $s_author2="select author_id from author where first_name=\"$a_first2\" and last_name=\"$a_last2\"";
       $results5 = @mysql_query($s_author2);
       $count5=mysql_fetch_array($results5);
       if(mysql_num_rows($results5)<1){
        $q_author2="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first2\", \"$a_last2\", \"$address\",  \"$zipcode\", \"$telephone\", \"$email\")";
        $result2 = @mysql_query($q_author2);
        if($result2){
                   $author_id= mysql_insert_id();
          }

    }
    else
        $author_id =$count5[0];
    if($books_id!=""||$author_id!=""){
           $s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
           $resulta = @mysql_query($s_ba);
           //$counta=mysql_fetch_array($resulta);
           if(mysql_num_rows($resulta)<1){
            $q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
            $author_id="";
            $resulta = @mysql_query($q_books_author);
        }
    }

}
if(($a_first3!="")||($a_last3!="")){
    $a_first3=trim($a_first3);
    $a_last3=trim($a_last3);
       $s_author3="select author_id from author where first_name=\"$a_first3\" and last_name=\"$a_last3\"";
       $results6 = @mysql_query($s_author3);
       $count6=mysql_fetch_array($results6);
       if(mysql_num_rows($results6)<1){
        $q_author3="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first2\", \"$a_last2\", \"$address\",  \"$zipcode\", \"$telephone\", \"$email\")";
        $result3 = @mysql_query($q_author3);
        if($result3){
                   $author_id= mysql_insert_id();
          }

    }
    else
        $author_id =$count6[0];
    if($books_id!=""||$author_id!=""){
           $s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
           $resulta = @mysql_query($s_ba);
           //$counta=mysql_fetch_array($resulta);
           if(mysql_num_rows($resulta)<1){
            $q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
            $author_id="";
            $resulta = @mysql_query($q_books_author);
        }
    }

}

echo"<BR><A HREF = $PHP_SELF>返回 </A>";
echo"</BODY></HTML>";

?>
<?
endif;
?> 

    
最新技术文章:
▪PHP函数microtime()时间戳的定义与用法
▪PHP单一入口之apache配置内容
▪PHP数组排序方法总结(收藏)
▪php数组排序方法大全(脚本学堂整理奉献)
▪php数组排序的几个函数(附实例)
jquery iis7站长之家
▪php根据键值对二维数组排序的小例子
▪php验证码(附截图)
▪php数组长度的获取方法(三个实例)
▪php获取数组长度的方法举例
▪判断php数组维度(php数组长度)的方法
▪php获取图片的exif信息的示例代码
▪PHP 数组key长度对性能的影响实例分析
▪php函数指定默认值的方法示例
▪php提交表单到当前页面、提交表单后页面重定...
▪php四舍五入的三种实现方法
▪php获得数组长度(元素个数)的方法
▪php日期函数的简单示例代码
▪php数学函数的简单示例代码
▪php字符串函数的简单示例代码
▪php文件下载代码(多浏览器兼容、支持中文文...
▪php实现文件下载、支持中文文件名的示例代码...
▪php文件下载(防止中文文件名乱码)的示例代码
▪解决PHP文件下载时中文文件名乱码的问题
▪php数组去重(一维、二维数组去重)的简单示例
▪php小数点后取两位的三种实现方法
▪php Redis 队列服务的简单示例
▪PHP导出excel时数字变为科学计数的解决方法
▪PHP数组根据值获取Key的简单示例
▪php数组去重的函数代码示例
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3