构建简单的Webmail系统

小生近日来学习Mysql数据库,自己编写一个用IE远程创建Mysql数据库的简易程序,此程序适用与对Mysql数据库一无所知的人,可以轻松的创建Mysql数据库及数据库中的各种类型的表,而且完全是图形界面,你甚至可以一句sql语句都不知道,我编写的这个程序可能尚还十分简陋,在此我只想起一个抛砖引玉的作用,希望大家能不断完善此程序,做一个真正意义上的图形界面的Mysql管理器.
此程序共分两个文件: mkdb.htm:搜集使用者信息,给下面的.php文件使用. HTML
HEAD TITLEMYSQL数据库创建单/TITLE /HEAD BODY FORM METHOD=”POST”
ACTION=”MKDB.PHP” TABLE WIDTH=400 BORDER=1 CELLSPACING=0 CELLPADDING=0
TR TD ALIGN=CENTER COLSPAN=2创建一个新的数据库/TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入数据库名:/TD TD WIDTH=250 ALIGN=CENTER INPUT TYPE=TEST
SIZE=30 VALUE=DATABASE NAME=DATABASENAME /TD /TR TR TD ALIGN=CENTER
COLSPAN=2 INPUT TYPE=SUBMIT VALUE=创建数据库 NAME=SWCODE /TD /TR /TABLE
/FORM FORM METHOD=”POST” ACTION=”MKDB.PHP” TABLE WIDTH=400 BORDER=1
cellspacing=0 cellpadding=0 TR TD ALIGN=CENTER
COLSPAN=2删除一个已有的数据库/TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入数据库名:/TD TD WIDTH=250 ALIGN=CENTER INPUT TYPE=TEST
SIZE=30 VALUE=DATABASE NAME=DATABASENAME /TD /TR TR TD ALIGN=CENTER
COLSPAN=2 INPUT TYPE=SUBMIT VALUE=删除数据库 NAME=SWCODE /TD /TR /TABLE
/FORM FORM METHOD=”POST” ACTION=”MKDB.PHP” TABLE WIDTH=500 BORDER=1
cellspacing=0 cellpadding=0 TR TD ALIGN=CENTER
COLSPAN=2在一个已有的数据库中创建表/TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入数据库名:/TD TD WIDTH=350 INPUT TYPE=TEST SIZE=30
VALUE=DATABASE NAME=DATABASENAME /TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入表名:/TD TD WIDTH=350 INPUT TYPE=TEST SIZE=30
VALUE=TESTABLE NAME=TABLENAME /TD /TR TR TD ALIGN=CENTER COLSPAN=2 TABLE
WIDTH=500 BORDER=1 cellspacing=0 cellpadding=0 TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
VALUE=IDX NAME=FIELDNAME[1]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD
WIDTH=175 ALIGN=CENTER SELECT NAME=TYPE[1] SIZE=1 OPTION
VALUE=INTEGER(10) SELECTED普通整型/OPTION OPTION
VALUE=TINYINT(3)短整型/OPTION OPTION
VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[2]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[2] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[3]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[3] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[4]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[4] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[5]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[5] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[6]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[6] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[7]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[7] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[8]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[8] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[9]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[9] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR TR TD WIDTH=75
ALIGN=CENTER字段名/TD TD WIDTH=175 ALIGN=CENTERINPUT TYPE=TEST SIZE=20
NAME=FIELDNAME[10]/TD TD WIDTH=75 ALIGN=CENTER字段类型/TD TD WIDTH=175
ALIGN=CENTER SELECT NAME=TYPE[10] SIZE=1 OPTION
VALUE=INTEGER(10)普通整型/OPTION OPTION VALUE=TINYINT(3)短整型/OPTION
OPTION VALUE=FLOAT(10,4)单精度浮点型/OPTION OPTION
VALUE=DOUBLE(10,4)双精度浮点型/OPTION OPTION VALUE=DATE日期型/OPTION
OPTION VALUE=VARCHAR(255)可变字符型/OPTION OPTION
VALUE=CHAR(20)字符型(20个字符)/OPTION OPTION VALUE=NONE
SELECTED空字段/OPTION /SELECT /TD /TR /TABLE /TD /TR TR TD ALIGN=CENTER
COLSPAN=2 INPUT TYPE=SUBMIT VALUE=创建表 NAME=SWCODE /TD /TR /TABLE
/FORM FORM METHOD=”POST” ACTION=”MKDB.PHP” TABLE WIDTH=400 BORDER=1
CELLSPACING=0 CELLPADDING=0 TR TD ALIGN=CENTER
COLSPAN=2删除一张已有的表/TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入数据库名:/TD TD WIDTH=250 ALIGN=CENTER INPUT TYPE=TEST
SIZE=30 VALUE=DATABASE NAME=DATABASENAME /TD /TR TR TD WIDTH=150
ALIGN=CENTER请输入表格名称:/TD TD WIDTH=250 ALIGN=CENTER INPUT TYPE=TEST
SIZE=30 VALUE=TESTABLE NAME=TABLENAME /TD /TR TR TD ALIGN=CENTER
COLSPAN=2 INPUT TYPE=SUBMIT VALUE=删除表 NAME=SWCODE /TD /TR /TABLE
/FORM /BODY /HTML mkdb.php:通过函数联系mysql. HTML HEAD
TITLEMYSQL数据库创建结果/TITLE ?php function showdb($result) { echo
“CENTERTABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0 TR TD
WIDTH=100 ALIGN=CENTER数据库序号/TD TD WIDTH=250 ALIGN=CENTER数据库名/TD
/TR”;$i=0; while($row=mysql_fetch_array($result)) { $i=$i+1; echo
“TRTD WIDTH=100 ALIGN=CENTER$i/TD”; echo “TD WIDTH=250 ALIGN=CENTER”;
echo $row[“Database”]; echo “/TD/TR/CENTER”; } } function
showcol($result) { echo “CENTERTABLE BORDER=1 WIDTH=350 CELLSPACING=0
CELLPADDING=0 TR TD WIDTH=100 ALIGN=CENTER字段名/TD TD WIDTH=250
ALIGN=CENTER字段类型/TD /TR”;$i=0;
while($row=mysql_fetch_array($result)) { echo “TRTD WIDTH=100
ALIGN=CENTER”; echo $row[“Field”]; echo “/TD”; echo “TD WIDTH=250
ALIGN=CENTER”; echo $row[“Type”]; echo “/TD/TR/CENTER”; } } function
showtab($result,$DATABASENAME) { echo “CENTERTABLE BORDER=1 WIDTH=350
CELLSPACING=0 CELLPADDING=0 TR TD WIDTH=100 ALIGN=CENTER表格序号/TD TD
WIDTH=250 ALIGN=CENTER表格名称/TD /TR”;$i=0;
while($row=mysql_fetch_array($result)) { $i=$i+1; echo “TRTD WIDTH=100
ALIGN=CENTER$i/TD”; echo “TD WIDTH=250 ALIGN=CENTER”; echo
$row[“Tables_in_”.$DATABASENAME]; echo “/TD/TR/CENTER”; } } function
creatdb($dbname) { $result=mysql_create_db($dbname); if ($result){
echo “CENTERTABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0TRTD
ALIGN=CENTER”; echo “H4$dbname 创建成功!/H4”; echo
“/TD/TR/TABLE/CENTER”;} else{ echo “CENTERTABLE BORDER=0 WIDTH=350
CELLSPACING=0 CELLPADDING=0TRTD ALIGN=CENTER”; echo “H4创建失败!/H4”;
echo “/TD/TR/TABLE/CENTER”;} } function dropdb($dbname) {
$result=mysql_drop_db($dbname); if ($result){ echo “CENTERTABLE
BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0TRTD ALIGN=CENTER”; echo
“H4$dbname 成功删除!/H4”; echo “/TD/TR/TABLE/CENTER”;} else{ echo
“CENTERTABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0TRTD
ALIGN=CENTER”; echo “H4删除失败!/H4”; echo “/TD/TR/TABLE/CENTER”;} } ?
/HEAD BODY CENTERH3数据库创建结果如下:/H3/CENTER ?php
$result=mysql_connect(); switch($SWCODE){ case 创建数据库:
creatdb($DATABASENAME); echo “CENTERH4目前数据库列表如下:/H4/BR/CENTER”;
$result=mysql_list_dbs(); showdb($result); break; case 删除数据库:
dropdb($DATABASENAME); echo “CENTERH4目前数据库列表如下:/H4/BR/CENTER”;
$result=mysql_list_dbs(); showdb($result); break; case 创建表: if
(mysql_select_db($DATABASENAME)) { if
(mysql_db_query($DATABASENAME,”select * from $TABLENAME”)) echo
“H4CENTER在数据库: $DATABASENAME 中已存在 $TABLENAME
表。请检查表名称!/CENTER/H4”; else { $string=”CREATE TABLE
“.$TABLENAME.”(“; if ($TYPE[1]”NONE”)$string=$string.$FIELDNAME[1].”
“.$TYPE[1]; for($i=2;$i=10;$i++) { if
($TYPE[$i]”NONE”)$string=$string.”,”.$FIELDNAME[$i].” “.$TYPE[$i];
} $string=$string.”)”;
$result=mysql_db_query($DATABASENAME,”$string”); if ($result) {
echo”H4CENTER成功的在数据库: $DATABASENAME 中创建 $TABLENAME
表!/CENTER/H4″; $result=mysql_db_query($DATABASENAME,”SHOW COLUMNS
FROM $TABLENAME”); showcol($result); } else { echo “H4CENTER在数据库:
$DATABASENAME 中创建 $TABLENAME 表的动作失败!请检查原因!/CENTER/H4”; }
} } else echo “CENTERH4此数据库不存在!请检查数据库名。/H4/BR/CENTER”;
$result=mysql_db_query($DATABASENAME,”SHOW TABLES”); if ($result) {
echo “CENTERH5在”.$DATABASENAME.”中已存在的表格如下所示:/H5/CENTER”;
showtab($result,$DATABASENAME); } break; case 删除表: if
(mysql_select_db($DATABASENAME)) {
$result=mysql_db_query($DATABASENAME,”DROP TABLE $TABLENAME”); if
($result) { echo
“CENTERH3已成功的在数据库”.$DATABASENAME.”中将表”.$TABLENAME.”删除/CENTER/H3″;
$result=mysql_db_query($DATABASENAME,”SHOW TABLES”); if ($result) {
echo “CENTERH5在”.$DATABASENAME.”中已存在的表格如下所示:/H5/CENTER”;
showtab($result,$DATABASENAME); } } else { echo
“CENTERH3在数据库”.$DATABASENAME.”中未将表”.$TABLENAME.”删除!/CENTER/H3″;
$result=mysql_db_query($DATABASENAME,”SHOW TABLES”); if ($result) {
echo “CENTERH5在”.$DATABASENAME.”中已存在的表格如下所示:/H5/CENTER”;
showtab($result,$DATABASENAME); } } } else echo
“CENTERH3数据库”.$DATABASENAME.”不存在!/H3/CENTER”; break; default:
echo “centerh2你什么事都没干!/h2/center”; break; } ? /BODY /HTML
使用时,需将着两个文件分别放到Apache的访问目录下,并用IE访问mkdb.html便可.

这是一段Web
Mail的示范代码,功能不是很强,但是结构还比较完整,主要的功能如查看文件夹,查看信件,回复,写信都有。但是程序中没有考虑附件解读和发送的问题。
(原文在
这里)。仅推荐给希望了解Webmail编程的网友做个参考。更加完善的Webmail请大家到
这里查找。
请注意:程序中使用了http认证功能,此功能需配合apache服务器使用。

图书目录输入部分: ? if(!$UploadAction): ? ?
//本程序是为输入书名,作者、出版社资料而设。
//编者:孔秀祥。日期:2001/3/24 /* session_start(); if
(!isset($auth_passed)) { echo 本功能只有授权用户才能使用。; return -1;
} if(isset($u_name)) { session_name($u_name); //echo centerfont
color=’red’.session_name().:本程序将竭诚为您服务。/font/center/n;
//echo hr; } */ ? HTMLHEAD TITLE图书目录输入 /TITLE /HEAD BODYTABLE
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
!–TRTD文件名TDINPUT NAME = UploadFile TYPE = file VALUE= SIZE = 30/TR–
TRTD 著作名TDINPUT NAME = b_name TYPE = text VALUE= SIZE = 30
maxlength=100/TD/TR TRTD 作者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 TRTD 作者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 TRTD 作者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 TRTD 出版社TDINPUT NAME = p_name TYPE = text
VALUE= SIZE = 30 maxlength=100/TD/TR TRTD出版日期TDINPUT NAME = p_year
TYPE = text VALUE= SIZE = 4年 INPUT NAME = p_month TYPE = text VALUE=
SIZE = 2月TRTDISBNTDINPUT NAME = isbn TYPE = text VALUE= SIZE = 25 TRTD
rowspan=5有关书的说明/TD !–/TRTR– TD rowspan=5TEXTAREA wrap=on rows=5
cols=30 NAME = b_comment SIZE = 255 /TEXTAREA/TD /TR /TABLE TABLE TRTD
INPUT NAME = submit VALUE = 提交 TYPE = submit TDINPUT 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 BRfont
color=’blue’作者:/font.$first_name.$last_name; echo BRfont
color=’red’国标标准书号:/font.$count[5]; echo BRfont
color=’blue’书价:/font.$count[6].元; echo BRfont
color=’red’出版日期:/font.substr($count[7],0,4).年.substr($count[7],5,2).月;
if($count[8]) echo font color=’blue’页码:/font.$count[8].页;
echoBRA 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); } } } echoBRA HREF = $PHP_SELF返回
/A; echo/BODY/HTML; ? ? endif; ?


将以下代码分别存为 index.php3, imapfuncs.phl
配置imapfuncs.phl文件中的$M_HOST = “localhost”; $M_MAILSERVER =
“transit.fast.no”;

然后浏览 index.php3 即可.  

index.php3

<?PHP
/* $Id: index.php3,v 1.3 1999/04/14 12:12:32 borud Exp $ */

/* load the IMAP library functions we’ve written */
include(“imapfuncs.phl”);

m_login($m);

?>
<HTML>
<HEAD>
<TITLE><?PHP echo “$M_SYSNAME”; ?></TITLE>
</HEAD>
<BODY bgcolor=#AAAAAA text=#000000 link=#440000 vlink=#440000
alink=#FF00FF>
<H1 ALIGN=CENTER><?PHP echo “$M_SYSNAME”; ?></H1>
<HR SIZE=1 NOSHADE>

<P>
<?PHP
if ($cmd == “delete”) {
m_delete($marked, $m);
m_list($m);
}

elseif ($cmd == “display”) {
m_display($n, $m);
}

elseif ($cmd == “compose” || $cmd == “reply”) {
m_compose($n, $m);
}

elseif ($cmd == “send”) {
m_send($to, $subject, $body);
m_list($m);
}

else {
m_list($m);
}
?>

<P>

<HR SIZE=1 NOSHADE>
<?PHP echo “User: $PHP_AUTH_USER”; ?>

</BODY>
</HTML>


imapfuncs.phl

<?PHP /* -*-C++-*- */

/* $Id: imapfuncs.phl,v 1.4 1999/04/14 12:12:32 borud Exp $ */

/* configurable parameters */

$M_HOST = “localhost”;
$M_MAILSERVER = “transit.fast.no”;

$M_COLOR_ODD = “#CCCCCC”;
$M_COLOR_EVEN = “#EEEEEE”;
$M_COLOR_HEAD = “#AAAAFF”;
$M_COLOR_BG = “#FFFFFF”;

/* globals */
$M_PORT = 143;
$M_SERVICE = “imap”;
$M_SYSNAME = “Simple PHP3 IMAP Interface 1.0”;
$M_MBOX = “{$M_HOST:$M_PORT/$M_SERVICE}”;
$M_REALM = “IMAP Interface”;
$MBOX = false;

/* functions */

function m_login ($mailbox = ”)
{
global $MBOX, $M_REALM;
global $PHP_AUTH_USER, $PHP_AUTH_PW;

if ($MBOX) {
return true;
}

if (! $PHP_AUTH_USER) {
m_reject($M_REALM);
}

$MBOX = @imap_open(m_mailbox_name($mailbox), $PHP_AUTH_USER,
$PHP_AUTH_PW);

if (! $MBOX) {
m_reject($M_REALM);
}

return true;
}

function m_list($mailbox = ”)
{
global $MBOX, $PHP_SELF;
global $M_COLOR_ODD, $M_COLOR_EVEN, $M_COLOR_HEAD,
$M_COLOR_BG;

/* if not logged into server, do so */
if (! $MBOX) {
if (! m_login($mailbox)) {
return false;
}
}

$num = imap_num_msg($MBOX);

echo “<FORM ACTION=$PHP_SELF TYPE=POST>n”;
echo “<CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1
WIDTH=90%>n”;

echo “<TR ALIGN=LEFT BGCOLOR=$M_COLOR_HEAD>”;
echo “<TH>
</TH><TH>From</TH><TH>Subject</TH><TH>Date</TH>”;
echo “</TR>n”;

for ($i=1; $i < ($num+1); $i++) {
$head = imap_header($MBOX, $i, 50, 50, 0);

$from = $head->fetchfrom;
$subj = $head->fetchsubject;
$date = m_date_format($head->date);

$bgcolor = ($i%2 == 0)?$M_COLOR_ODD:$M_COLOR_EVEN;

echo “<TR BGCOLOR=”$bgcolor”>n”;
echo ” <TD><INPUT TYPE=CHECKBOX NAME=marked[]
VALUE=$i></TD>n”;
echo ” <TD>$from</TD>”;
echo “<TD><A
href=”$PHP_SELF?m=$mailbox&n=$i&cmd=display”>$subj</A></TD>”;
echo “<TD>$date</TD>n”;
echo “</TR>n”;
}

if ($num <= 0) {
echo “<TR><TD ALIGN=CENTER COLSPAN=4
BGCOLOR=$M_COLOR_BG><BR>”;
echo “<FONT SIZE=+1 COLOR=#FF0000>No messages in
mailbox</FONT>”;
echo “<BR><BR></TD></TR>n”;
}

echo “<TR BGCOLOR=$M_COLOR_HEAD><TD COLSPAN=4>”;
echo “<INPUT TYPE=submit NAME=cmd VALUE=delete>”;
echo “<INPUT TYPE=submit NAME=cmd VALUE=compose>”;
echo “<INPUT TYPE=submit NAME=cmd VALUE=refresh>”;
echo “</TD></TR>n”;

echo “</TABLE></CENTER>n”;
echo “</FORM>n”;

return true;
}

function m_display($msgno, $mailbox = ”)
{
global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG;
global $PHP_SELF;

if (! $MBOX) {
if (! m_login($mailbox)) {
return false;
}
}

$struc = imap_fetchstructure($MBOX, $msgno);
if (! $struc) {
return false;
}

$head = imap_header($MBOX, $msgno, 50, 50, 0);

$from = $head->fromaddress;
$subj = $head->subject;
$date = $head->date;
$body = htmlentities(imap_body($MBOX, $msgno));

echo “<CENTER>n”;
echo “<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10
WIDTH=100%>n”;
echo “<TR BGCOLOR=$M_COLOR_HEAD><TH>Message #$msgno:
$from / $subj</TH></TR>n”;
echo “<TR BGCOLOR=$M_COLOR_BG><TD><PRE>n”;
echo “From: $fromn”;
echo “Subject: $subjn”;
echo “Date: $daten”;
echo “<HR SIZE=2 NOSHADE>n”;
echo “$bodyn”;
echo “</PRE></TD></TR>n”;
echo “<TR BGCOLOR=$M_COLOR_HEAD><TD>”;

echo “<FORM ACTION=$PHP_SELF METHOD=POST>”;
echo “<INPUT TYPE=HIDDEN NAME=m VALUE=$mailbox>n”;
echo “<INPUT TYPE=HIDDEN NAME=n VALUE=$msgno>n”;
echo “<INPUT TYPE=HIDDEN NAME=marked[] VALUE=$msgno>n”;
echo “<INPUT TYPE=SUBMIT NAME=cmd VALUE=back>”;
echo “<INPUT TYPE=SUBMIT NAME=cmd VALUE=reply>”;
echo ”     <INPUT TYPE=SUBMIT NAME=cmd VALUE=delete>”;

echo “</TD></TR>n”;
echo “</TABLE>n”;
echo “</CENTER>n”;

return true;
}

function m_delete ($msgno, $mailbox=”)
{
global $MBOX;

if (is_array($msgno)) {
while (list($dummy, $num) = each($msgno)) {
imap_delete($MBOX, $num);
}
imap_expunge($MBOX);
} else {
return false;
}

return true;
}

function m_compose ($msgno=”, $mailbox=”)
{
global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG;
global $PHP_SELF, $PHP_AUTH_USER, $M_MAILSERVER;

if ($msgno != ”) {
$head = imap_header($MBOX, $msgno, 150, 150, 0);
$to = $head->fromaddress;
$subject = “Re: ” . $head->subject;
$body = “$to wrote:n”;
$body .= ereg_replace(“n”,”n>”, “n” . imap_body($MBOX,
$msgno));
} else {
$to = “”;
$subject = “”;
$body = “”;
}

echo “<CENTER>n”;
echo “<FORM METHOD=POST ACTION=”$PHP_SELF”>n”;
echo “<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0>n”;
echo “<TR bgcolor=$M_COLOR_HEAD><TD
ALIGN=RIGHT>To:</TD>”;
echo “<TD><INPUT TYPE=TEXT NAME=to value=”$to”
SIZE=50></TD></TR>n”;

echo “<TR bgcolor=$M_COLOR_HEAD><TD
ALIGN=RIGHT>Subject:</TD>”;
echo “<TD><INPUT TYPE=TEXT NAME=subject value=”$subject”
SIZE=50></TD></TR>n”;

echo “<TR bgcolor=$M_COLOR_BG><TD COLSPAN=2>”;
echo “<TEXTAREA COLS=76 ROWS=10 NAME=body
WRAP=hard>$body</TEXTAREA>”; 

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图