add_item.php

来自「一个用php+mysql做的图书馆管理系统」· PHP 代码 · 共 73 行

PHP
73
字号
<?php
/**************************************************************************************

    Simple Library System
    Copyright (C) 2002 John Mark Matthews

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    For further information, contact:
    	John Matthews
    	jmatthews@exostrategy.com

***************************************************************************************/

include("mainfile.inc");
include("header.inc");
include("footer.inc");
include("auth.inc");

reg('POST','submit', 'item_type', 'title', 'author', 'subject', 'abstract');

if($global_is_admin) {
	if($item_type && $title) {
		$sql = "insert into tbl_item(item_type,title,subject,author,status,abstract) values(";
		$sql.= "$item_type,'$title','$subject','$author',1,'$abstract')";
		mysql_query($sql);
		$item_id = mysql_insert_id();

		mysql_query("insert into tbl_review_summary(item_id,avg_grade,total_review) values ($item_id,0,0)");
		head();
		menu();
		echo Paragraph(Bold("You have added the following item:"));
		PrintItem($item_id);
		foot();

	}else{
		$t="";
		$t = MakeSelectArray("select item_type, item_type_desc from tbl_item_type order by item_type_desc");

		$subject_list="";
		$subject_list = MakeSelectArray("select subject, subject from tbl_subject order by subject");

		head();
		menu();
		OpenForm();
		OpenTable();
		echo Row(Cell("Type:").    Cell(MakeSelect("item_type",-1,$t)));
		echo Row(Cell("Title:").   Cell("<input name='title' type='text' size=80>"));
		echo Row(Cell("Author:").  Cell("<textarea wrap='virtual' cols='80' rows='3' name='author'></textarea>"));
		echo Row(Cell("Subject:"). Cell(MakeSelect("subject",-1,$subject_list)));
		echo Row(Cell("Abstract:").Cell("<textarea wrap='virtual' cols='80' rows='12' name='abstract'></textarea>"));
		echo Row(Cell().Cell());
		echo Row(Cell("<input align='center' name='login' type='submit' value = 'Add Item'>","colspan=4 align=center"));
		CloseTable();
		CloseForm();
		foot();
	}
}else{
	header("Location: ./index.php");
}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?