会议记录管理系统(4)
来源:互联网 发布:第一初恋网络剧百度云 编辑:程序博客网 时间:2024/04/29 10:13
1.会议记录添加模块概述
系统正常登录后,每一个用户都有权利添加新的会议,供本部门成员和其他部门成员阅读浏览。
2.会议记录信息验证技术
向数据库中添加新会议记录时,系统必须保证用户提交的信息不为空。这里应用JavaScript脚本判断上传数据是否为空,在js文件夹下创建add_meeting.js文件,编写check_submit()方法,验证表单提交的数据是否为空。关键代码如下:
function check_submit(){ if(theForm.meeting_name.value==""){ alert("会议名称不能为空!"); theForm.meeting_name.focus(); return false; } if(theForm.meeting_place.value==""){ alert("会议地点不能为空!"); theForm.meeting_place.focus(); return false; } if(theForm.meeting_host.value==""){ alert("会议主持人不能为空!"); theForm.meeting_host.focus(); return false; } if(theForm.meeting_saver.value==""){ alert("会议记录人不能为空!"); theForm.meeting_saver.focus(); return false; } if(theForm.meeting_present.value==""){ alert("出席人员不能为空!"); theForm.meeting_present.focus(); return false; } if(theForm.textarea.value==""){ alert("会议摘要不能为空!"); theForm.textarea.focus(); return false; } theForm.submit(); // 表单提交}
3.上传文件处理技术
本系统要求用户在上传会议记录的同时,必须上传文本文档格式的会议记录附件。所以又增加了上传文件和判断上传文件格式两项技术。
A.文件上传
文件上传应用的是move_uploaded_file函数和
注意:如果filename不是合法的上传文件,不会执行任何操作,move_uploaded_file()将返回false,如果参数filename是合法的上传文件,但出于某些原因无法移动,同样也不会执行任何操作,move_uploaded_file()将返回false.此外还会发出一条警告。
2)$_FILES全局变量
B.判断上传文件格式
用如下自定义函数完成,该函数存储于addmeeting_chk.php文件中,关键代码如下:
function f_postfix($f_type,$f_upfiles){ // 获取传递的参数值 $is_pass = false; $tmp_upfiles = split("\.",$f_upfiles); // 获取上传文件的后缀 $tmp_num = count($tmp_upfiles); // 统计返回值的元素数量 // 循环读取定义文件类型数组的值 for($num = 0;$num < count($f_type);$num++){ // 完成文件类型的大小写转换及判断 if(strtolower($tmp_upfiles[$tmp_num - 1]) == $f_type["num"]){ $is_pass = $f_type["num"]; // 获取文件类型 } } return $is_pass; // 返回上传文件的类型}
4.会议记录添加的实现过程
会议记录添加的操作是通过addmeeting.php与addmeeting_chk.php两个文件来实现的。
(1)在addmeeting.php文件中,创建添加会议记录信息的表单,通过JavaScript脚本对提交的元素进行判断,并且设置action属性值为addmeeting_chk.php。其关
关键代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body> <script> function checkSubmit(){ if(theForm.meeting_name.value==""){ alert("会议名称不能为空!"); theForm.meeting_name.focus(); return false; } // if(theForm.meeting_place.value=""){ // alert("会议地点不能为空!"); // theForm.meeting_place.focus(); // return false; // } // if(theForm.meeting_host.value=""){ // alert("会议主持人不能为空!"); // theForm.meeting_host.focus(); // return false; // } // if(theForm.meeting_saver.value=""){ // alert("会议记录人不能为空!"); // theForm.meeting_saver.focus(); // return false; // } if(theForm.meeting_present.value==""){ alert("出席人员不能为空!"); theForm.meeting_present.focus(); return false; } if(theForm.textarea.value==""){ alert("会议摘要不能为空!"); theForm.textarea.focus(); return false; } theForm.submit(); // 表单提交}</script><table cellpadding="0" cellspacing="0" border="0"> <form id="theForm" name="theForm" action="addmeeting_chk.php" method="post" onsubmit="return checkSubmit();" enctype="multipart/form-data"> <tr> <td colspan="3" height="32"> <h1 align="center">添加会议记录</h1> </td> </tr> <tr> <td width="120" height="28"><div align="center">会议名称:</div></td> <td><input class="input2" type="text" name="meeting_name" /></td> <td align="left" width="180"><span class="spl">*填写会议记录名称</span></td> </tr> <!-- 省略部分代码 --> <tr> <td height="28"><div align="center">出席人员:</div></td> <td><input class="input2" type="text" name="meeting_present" /></td> <td align="left" width="180"><span class="spl">*填写会议出席人员</span></td> </tr> <tr> <td height="28">上传会议内容</td> <td> <input class="upload" name="meeting_documents" type="file" size="16" /> </td> <td align="left" width="180"><span class="spl">*上传txt格式会议文稿</span></td> </tr> <tr> <td><div align="center">会议摘要:</div></td> <td height="70"> <textarea style="width:170px;border:1px solid #ccc;" name="textarea" rows="4"></textarea> </td> <td align="left" width="180"><span class="spl">*填写会议记录摘要</span></td> </tr> <tr><td height="12" colspan="3"></td></tr> <td height="30" colspan="2"> <center> <input class="add_mbtn1" type="submit" value="提交" /> <input class="add_mbtn2" type="reset" value="重置" /> </center> </td> </form></table></body></html>
(2)创建addmeeting_chk.php文件,接收表单提交的数据。首先,定义自定义函数用于验证上传文件的格式;然后对上传文件进行验证操作;最后,通过move_upload_file()函数执行文件的上传操作,并且将会议记录添加到指定的数据表中。其关键代码如下:
<?php header("Content-Type:text/html;charset=utf-8"); date_default_timezone_set('PRC'); // 设置为北京时间 session_start(); include_once("conn/conn.php"); // 判断上传格式是否符合上传要求 function f_postfix($f_type,$f_upfiles){ $is_pass = false; // 表示上传的文件格式非法 $tmp_upfiles = split("\.",$f_upfiles); // 返回由文件名和文件后缀组成的数组 $tmp_num = count($tmp_upfiles); // 返回数组长度 $f_typeLen = count($f_type); for($num = 0;$num < $f_typeLen;$num++){ $wjhz = $tmp_upfiles[$tmp_num - 1]; // 返回文件后缀 if(strtolower($wjhz) == $f_type[$num]){ $is_pass = $f_type[$num]; // 文件后缀合法 } } return $is_pass; } // 判断是否上传了文件 if($_FILES["meeting_documents"]["size"] <= 0){ // $_FILES["meeting_documents"]["size"]返回文件字节大小 echo "<script>alert('请上传文件');history.go(-1);</script>"; }else{ // 如果上传了文件 $f_type = array("txt"); // 定义上传文件的格式 $record_path = "upfile"; // 定义上传路径 $fileName = $_FILES["meeting_documents"]["name"]; $postf = f_postfix($f_type,$fileName); // 判断上传格式 if($postf != false){ $new_path = time().".txt"; // 以时间戳定义上传文件名称 // 判断用户上传文件大小是否超过10MB if($_FILES["meeting_documents"]["size"] > 0 and $_FILES["meeting_documents"]["size"] < 1000000){ // 定义上传文件在服务端的路径 $filepath = $record_path . "\\" . $new_path; // upfile... $filepath = addslashes($filepath); // addslashes函数,防止数据插入数据库时,斜杠被过滤掉 echo "文件服务端路径为:".$filepath."<br />"; // 数据库操作命令 $sqlstrii = "insert into tb_meeting_info(meeting_name,meeting_present,meeting_abstruct,meeting_address) values('$_POST[meeting_name]','$_POST[meeting_present]','$_POST[textarea]','$filepath)')"; // echo $sqlstrii; // 插入数据库 if( mysql_query($sqlstrii)){ // 上传文件操作 // $_FILES["meeting_documents"]["tmp_name"],存储文件在临时目录中使用的文件名。因为文件在上传时,首先要以临时文件的身份保存在临时目录中。 move_uploaded_file($_FILES["meeting_documents"]["tmp_name"],$filepath); echo "<script>alert('数据库添加成功!');history.go(-1);</script>"; }else{ echo "<script>alert('数据库添加失败!');history.go(-1);</script>"; } }else{ echo "<script>alert('文件大小超过10MB');history.go(-1);</script>"; } }else{ echo "<script>alert('上传只支持\".txt\"格式的文件');history.go(-1);</script>"; } }?>
- 会议记录管理系统(4)
- 会议记录管理系统(1)
- 会议记录管理系统(2)
- 会议记录管理系统(3)
- 会议记录管理系统(6)
- 会议记录管理系统(5) -浏览会议记录模块设计
- 软件项目管理-会议记录模板
- 会议记录
- 会议记录
- 在幼儿园管理系统中,会议管理>申请会议模块:添加会议记录(提交表单)的时候报:404错误!
- 会议记录4:3月22日
- [VB.NET源码]会议记录系统sql2000三层开发
- 5.22会议记录
- 第二次会议记录
- 会议记录范文
- 3.25会议记录
- 会议记录格式
- 会议记录模板
- Xpath helper Python爬虫工具谷歌浏览器插件
- Jetty服务器启动过程分析
- win7-opencv249-matlab-cuda7.5配置faster-rcnn
- STM32L系列flash操作陷阱
- PHP静态页面的日期时间获取
- 会议记录管理系统(4)
- vnuc5.0免费版(数控仿真软件下载附安装教程
- leetcode 599. Minimum Index Sum of Two Lists
- exit(1) exit(0) return 的用法与区别
- 新疆出差——特色美食大合集
- 数据结构实验之排序六:希尔排序
- Java实现短信验证码
- ubuntu16.04 安装 opencv3.3.0 源代码编译
- 打印动态红色心形