后台界面:
前台界面: 比较简单 可自行美化
文件结构:
enroll.php 文件在 plus文件下
enroll.htm文件在templets/plus 文件夹下
adenroll.php 文件在dede文件夹下
adenroll.html 文件dede/templet文件夹下
sql 文件:
01 |
CREATE TABLE IF NOT EXISTS `dede_enroll` ( |
02 |
`id` int (4) NOT NULL auto_increment, |
03 |
` name ` varchar (20) NOT NULL , |
04 |
`mail` varchar (30) NOT NULL , |
05 |
`tag` tinyint(1) NOT NULL default '0' , |
06 |
PRIMARY KEY (`id`) |
07 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; |
08 |
09 |
INSERT INTO `dede_plus` (`aid`, `plusname`, `menustring`, `mainurl`, `writer`, `isshow`, `filelist`) VALUES |
10 |
(30, '网上报名' , '<m:item name=' '网上报名' ' link=' 'adenroll.php' ' rank=' 'plus_网上报名' ' target=' 'main' ' />' , '' , 'g1000' , 1, '' ); |
11 |
12 |
INSERT INTO `dede_arctype` (`id`, `reid`, `topid`, `sortrank`, `typename`, `typedir`, `isdefault`, `defaultname`, `issend`, `channeltype`, `maxpage`, `ispart`, `corank`, `tempindex`, `templist`, `temparticle`, `namerule`, `namerule2`, `modname`, `description`, `keywords`, `moresite`, `sitepath`, `siteurl`, `ishidden`, ` cross `, `crossid`, `content`, `smalltypes`) VALUES |
13 |
(9, 0, 0, 50, '在线报名' , '{cmspath}/plus/enroll.php' , 1, 'enroll.php' , 0, 1, -1, 0, 0, '' , '' , '' , '' , '' , '' , '' , '' , 0, '' , '' , 0, 0, NULL , NULL , NULL ); |
这里说明下 为了方便 我简单的设置了 两个字段 姓名和邮箱 tag字段是标示是否录取 1为录取
第一个insert语句是添加到后台管理
第二个insert语句是添加到前台导航栏
enroll.php
01 |
<?php |
02 |
//*******要先包含common.inc.php 然后 session_start(); 否则取不到session的值 |
03 |
//*******因为common.inc.php 有关于session路径的配置 |
04 |
include_once dirname( __FILE__ ). './../include/common.inc.php' ; //包含配置文件 |
05 |
session_start(); |
06 |
require_once DEDEINC. "/arc.partview.class.php" ; //包含partiew类 |
07 |
//*****实例化 这个类的作用是得到头部导航栏和尾部信息 若不需要可以使用dedetemplate.class.php 这个类 |
08 |
$pv = new PartView(); |
09 |
if ( $_POST ){ |
10 |
if ( CheckEmail( $_POST [ 'mail' ])==false){ //验证邮箱 方法在common.func.php 公用函数 |
11 |
ShowMsg( '邮箱格式错误' , '-1' ); |
12 |
exit (); |
13 |
} |
14 |
if ( $_POST [ 'name' ]== "" ){ |
15 |
ShowMsg( '用户名不能为空' , '-1' ); |
16 |
exit (); |
17 |
} else { |
18 |
$name =htmlspecialchars( $_POST [ 'name' ]); |
19 |
} |
20 |
if ( $_SESSION [ 'dd_ckstr' ]!= strtolower ( $_POST [ 'validation' ])){ //验证 验证码 必须转换成小写 |
21 |
ShowMsg( '验证码错误' ,-1); |
22 |
exit (); |
23 |
} |
24 |
$sql = "insert into `dede_enroll`(name,mail) values('$name','$_POST[mail]')" ; |
25 |
//********$db可直接使用 系统自动实例化了dedesql.class.php |
26 |
$affected = $db ->ExecuteNoneQuery2( $sql ); //执行一条语句 返回影响值 |
27 |
if ( $affected ){ |
28 |
ShowMsg( '报名成功' ,-1); |
29 |
} |
30 |
} else { |
31 |
$pv ->SetTemplet(DEDETEMPLATE. '/plus/enroll.htm' ); //设置模板 |
32 |
$pv ->Display(); //显示页面 |
33 |
} |
34 |
35 |
?> |
enroll.htm
01 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
02 |
< head > |
03 |
< title >{dede:global.cfg_webname/}-在线报名</ title > |
04 |
< link href = "{dede:global.cfg_templeturl/}/style/dedecms.css" rel = "stylesheet" media = "screen" type = "text/css" /> |
05 |
</ script > |
06 |
</ head > |
07 |
< body > |
08 |
{dede:include filename="../default/head.htm"/} <!-- 包含头部 --> |
09 |
< blockquote style = "margin:50px auto" > |
10 |
< form method = "post" action = "" > |
11 |
姓 名:< input type = "text" size = 30 name = "name" />< br />< br /> |
12 |
邮 箱:< input type = "text" size = 30 name = "mail" />< br />< br /> |
13 |
<!--vdimgck.php 是验证码--> |
14 |
验证码:< input type = "text" name = "validation" />< img src = "../../include/vdimgck.php" />< br />< br /> |
15 |
< input name = "encoll" type = "submit" value = "报名" />< br /> |
16 |
</ form > |
17 |
</ blockquote > |
18 |
{dede:include filename="../default/footer.htm"/} <!-- 包含尾部 --> |
19 |
</ body > |
20 |
</ html > |
adenroll.php
01 |
<?php |
02 |
require_once (dirname( __FILE__ ). '/config.php' ); //后台配置文件 检查登陆 配置信息 |
03 |
require_once (DEDEINC. "/datalistcp.class.php" ); //包含分页类 |
04 |
if ( $_GET [ 'action' ]&& $_GET [ 'id' ]){ |
05 |
if ( $_GET [ 'action' ]== 'pass' ){ //各种操作 |
06 |
$db ->ExecuteNoneQuery( "update dede_enroll set `tag`=1 where id='$_GET[id]'" ); |
07 |
ShowMsg( '录取成功' , 'adenroll.php' ); |
08 |
} |
09 |
if ( $_GET [ 'action' ]== 'nopass' ){ |
10 |
$db ->ExecuteNoneQuery( "update dede_enroll set `tag`=0 where id='$_GET[id]'" ); |
11 |
ShowMsg( '取消录取' , 'adenroll.php' ); |
12 |
} |
13 |
if ( $_GET [ 'action' ]== 'delete' ){ |
14 |
$db ->ExecuteNoneQuery( "delete from dede_enroll where id='$_GET[id]'" ); |
15 |
ShowMsg( '删除成功' , 'adenroll.php' ); |
16 |
} |
17 |
} else { |
18 |
$dl = new DataListCP(); |
19 |
$dl ->pageSize = 10; //每页显示10条 |
20 |
$dl ->SetTemplate( './templets/adenroll.htm' ); //载入模板 |
21 |
$sql = "select * from dede_enroll" ; |
22 |
$dl ->SetSource( $sql ); //执行sql 不能与$dl->SetTemplate 颠倒 |
23 |
$dl ->Display(); //显示页面 |
24 |
} |
25 |
26 |
?> |
adenroll.html
01 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
02 |
< head > |
03 |
< title >在线报名管理</ title > |
04 |
< link href = 'img/base.css' rel = 'stylesheet' type = 'text/css' /> |
05 |
< style type = "text/css" > |
06 |
th,td{ |
07 |
text-align:center; |
08 |
border:1px #D1DDAA solid; |
09 |
font-size:15px; |
10 |
} |
11 |
th{ |
12 |
background:#E6F8B7; |
13 |
} |
14 |
table{ |
15 |
margin-top:20px; |
16 |
} |
17 |
</ style > |
18 |
</ head > |
19 |
< body > |
20 |
< table width = "90%" border = "0" cellpadding = "0" cellspacing = "0" align = "center" > |
21 |
< tr > |
22 |
< th >姓名</ th > |
23 |
< th >E-mail</ th > |
24 |
< th >状态</ th > |
25 |
< th >操作</ th > |
26 |
</ tr > |
27 |
<!-- 循环得到结果 --> |
28 |
{dede:datalist} |
29 |
< tr > |
30 |
< td >{dede:field.name /}</ td > |
31 |
< td >{dede:field.mail /}</ td > |
32 |
< td > |
33 |
{dede:if field.tag==0} |
34 |
未录取 |
35 |
{else} |
36 |
< font color = "red" >已录取</ font > |
37 |
{/dede:if} |
38 |
</ td > |
39 |
< td > < a href = "adenroll.php?action=pass&id={dede:field.id /}" >[录取]</ a > |
40 |
| |
41 |
< a href = "adenroll.php?action=nopass&id={dede:field.id /}" >[不通过]</ a > |
42 |
| |
43 |
< a href = "adenroll.php?action=delete&id={dede:field.id /}" >[删除]</ a > |
44 |
</ td > |
45 |
</ tr > |
46 |
{/dede:datalist} |
47 |
</ table > |
48 |
<!-- 分页标签 --> |
49 |
< p style = "text-align:center;font-size:15px;" >{dede:pagelist listitem="info,index,end,pre,next,pageno" listsize="5"/}</ p > |
50 |
</ body > |
51 |
</ html > |