摘要 本网站所用的软件有:php(后台处理) ,html(架设网站结构),css(网站样式的规划),mysql (贮藏数据)。能实现 查看、删除、插入三种功能。
任何一个人都可以加入记录,同时也可以删除记录,这不受任何限制,这是不全面的, 也是不安全的,这里没有设置登陆界面,需改进(设置管理员账号和密码就可以达到安全了)。
本网站主要有以下几个界面,分别为:indexqiu.php(主界面).showly.php(显示留言信息界面).showqiu.php(显示求职信息界面),insertly.php(插入留言信息界面),showtables.php(显示招聘信息界面),insertqiu.php(插入求职信息界面)等网页界面,还有以下几个后台处理程序:connect.php(连接数据库程序), checkly.php(处理留言信息并把它加入到数据库中), process1.php(处理求职信息并把它加入到数据库中),delly.php(从数据库中删除留言记录),delqiu.php(从数据库中删除求职记录),css.css(网页中样式的定义)。
四、各个界面的功能及代码剖析:
第一个界面(indexqiu.php)显示招聘信息界面,界面效果如下;
代码如下:
<html>
<head>
<link rel=stylesheet type=text/css href="css.css">//调用css.css程序
<style type="text/css"> //css.css设置
<!--
body,td,th{
font-family: Arial, Helvetica, sans-serif;
}
.style40 {color: #000000}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
<table width="100%" border="1">
<tr>
<td>
<div id="header">
<table height="60" width="100%" border=1 bordercolorlight="#E5F8F7" bordercolordark="#FFFFFF"
>
<tr>
<td width="100%" height="60">
<img src="../ground/weibo11.psd.jpg" width="100%" height="60">
</td>
</tr>
</table>
</div>
<table border="1" width="100%" bordercolorlight="#E5F8F7" bordercolordark="#FFFF
<tr>
<td width="250" align="center">
<?php //php程序开始
$day=date("Y年m月d日"."H:i");//利用php调用系统时间并显示在网页中
print "$day ";
switch(date("D"))
{
case "Mon":echo"星期一";
break;
case "Tue":echo"星期二";
break;
case "Wen":echo"星期三";
break;
case "Thu":echo"星期四";
break;
case "Fri":echo"星期五";
break;
case "Sat":echo"星期六";
break;
default:echo"星期日";
break;
}
?>//php程序结束
</td> <! 下面这些是超接链接>
<td width="100" align="center"><a href="index.php">本站首页</a></td>
<td width="100" align="center"><a href="showly.php">查看留言信息</a></td>
<td width="100" align="center"><a href="showqiu.php">查看求职信息</a></td>
<td width="100" align="center"><a href="inzhp.php">注册招聘信息</a></td>
<td width="100" align="center"><a href="amdzhp.php">管理招聘信息</a></td>
<td width="100" align="center"><a href="seazhp.php">查询招聘信息</a></td>
</tr>
</table>
<table width="100%" height="100%" border="1" bordercolorlight="#E5F8F7" bordercolordark="#FFFFF
F">
<tr>
<td height="100%" valign="top" style="font-size:10.5pt">
<? include"showtable.php"; ?> //利用php程序调用showtable.php(显示招聘信息)程序
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><hr size="1"></td>
</tr>
</table>
<table border="0" width="100%"> //作者的信息
<tr>
<td align="center" style="font-size:10.5pt"><span class="style40">
[作者:Zhou Minghong]
[E_mail:<a href="maikey4561@163.com">maikey4561@163.com</a>]
[QQ:250431233 || 471882325]
</td>
</tr></table>
</td>
</tr>
</table>
</body>
</html>
第一个部分为页面头部,是一张图片,作为修饰页面,第二个部分,显示时间,并列出相关主题的超接链接。第三部分是一个调用外部程序(showtable.php),用来显法招聘信息。
显示留言信息程序代码:
第二个界面(显示留言界面showly.php),本界面效果如下:
程序代码如下:
<?php session_start(); ?>//使用会话记录id的值,方便后面页面使用。
<html>
<head>
<style> <!这里为css样式设置>
body {font-family:"黑体";font-size:9pt}
table {font-size:9pt}
td {font-family:"黑体";font-size:9pt;line-heigth:14pt;letter-spacing:1pt}
a:link{text-decoration:none;color:black}
a:visited {text-decoration:none;color:black}
a:visited {text-decoration:underline;color:green}
.ourfont {font-size:9pt;}
-->
</style>
<title>留言溥</title>
</head>
<body topmargin="8" bgcolor="#ffffff">
<table width="100%">
<tr>
<td>
<div align="center">
<center>
<?php
include "connect.php";//调用连接数据库程序connect.php
$query="select * from sub";//打开sub表,并进行分析,然后汇总
$result=mysql_query($query);
$rows=mysql_num_rows($result);
?>
<table border="1" width="90%" cellspacing="0"cellpadding="0" bgcolor="#E5F8F
ht="#c2c2c2" bordercolordark="#ffffff">
<tr>
<td width="100%" bacdground="" style="font-size:10.5pt">
<font color="#00800">兴义师专计科系01级4班</font>
<?
for($i=0;$i<40;$i++)
echo" ";
?>
共有
<font color=orange>
<?echo"$rows"?>//显示所有记录条数。
</font>位同学</td>
</tr>
<tr>
<td width="100%">
<?php
$day=date("Y年m月d日"."H:i");
print "$day ";
switch(date("D")){
case "Mon":echo"星期一";
break;
case "Tue":echo"星期二";
break;
case "Wen":echo"星期三";
break;
case "Thu":echo"星期四";
break;
case "Fri":echo"星期五";
break;
case "Sat":echo"星期六";
break;
default:echo"星期日";
break;
}
?>
<?
for($i=0;$i<45;$i++) echo" ";
?>
[<a href="insertly.php">我要留言</a>]
</td>
</tr>
</table>
<table border="1" width="90%" cellspacing="0"
cellpadding="0" bgcolor="#E5F8F7" bordercolorrlight="#c2c2c2"
bordercolordark="#ffffff">
<tr>
<th width+"10">序号</th>
<th width="72">主题</th>
<th width="67">姓名</th>
<th width="92">邮件</th>
<th width="85">地址</th>
<th width="76">时间</th>
<th width="57">操作</th>
</tr>
<?
for($i=0,$j=0;$i<$rows;$i++,$j++)//用for循环显示数据,并根据记录的条数设置表格的交叉显示颜色。
{
$bg=$j%2?"ccffee":"cceeee";//两种交叉显示颜色。
mysql_data_seek($result,$i);
$r=mysql_fetch_array($result);//用数组形式来保存数据。
$_SESSION["id"]=$r[id];
$subj=$r[subj];
$name=$r[name];
$email=$r[email];
$addr=$r[addr];
$time=$r[time];
echo "<tr bgcolor=$bg align=center>";
?>
<! 用html来输出数据库中的记录>
<td width="36" align="center"> <? echo $_SESSION["id"] ?></td>
<td width="72" align="center"> <? echo "$subj" ?></td>
<td width="67" align="center"> <? echo "$name" ?></td>
<td width="92" align="center"> <? echo "$email" ?></td>
<td width="85" align="center"> <? echo "$addr" ?></td>
<td width="76" align="center"> <? echo "$time" ?></td>
<td width="57" align="center">
<a href="xxxs.php?id=<? echo $_SESSION["id"] ?>">//调用会话
<img src="../ground/all.gif" alt="详细显示" border="0" width="13" height="11"></a>
<a href="xiugai.php?id=<? echo $_SESSION["id"] ?>">
<img src="../ground/edit.gif" alt="修改" border="0" width="13" height="11"></a>
<a href="delly.php?id=<? echo $_SESSION["id"]?>">
<img src="../ground/de.gif" alt="删除" border="0" width="13"height="11"</a>
</td>
</tr>
<?php
}
?>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td><hr size="1"></td>
</tr>
</table>
<table border="1" width="90%" cellspacing="0" cellpadding="0" bgcolor="#E5F8
F7" bordercolorlight="#c2c2c2"
bordercolordark="#ffffff" background="">
<tr>
<td align="center" style="font-size:10.5pt">
作者:Zhou Minghong
E_mail:<a href="maikey4561@163.com">maikey4561@163.com</a>
<a href="indexqiu.php">返 回</a>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</body>
</thml>
删除留言界面(delly.php),该界面首先用会话调用上一个页面(showly.php)的id号,并且将其所对应的内容删除,同时删除id字段,又建立id字段,这样做的目的是让数据库中的id一直都保持从最小开始记录,即从0开始。如果没有删除,则给出不能删除的原因,并退出该程序的运行。
<?php
session_start();
echo "<meta http-equiv=/"Refresh/" Content=/"0;URL=showly.php/">";
echo "<meta http-equiv=/"Pragma/" Content=/"no-cache/">";
include("connect.php");
$query1="select * from sub order by id asc";
$r=mysql_query($query1);
$row=mysql_num_rows($r);
$id=$_SESSION["id"]-$row+1; //让id从最小开始显示。
$query="delete from sub where id=$id";
$rr=mysql_query($query);
if($rr){
echo"第.$id.条记录已被成功删除!";
$dat1="alter table sub drop id";
$d=mysql_query($dat1);
if($d){
echo"删除了字段id";
}
$dat2="alter table sub add id int primary key auto_increment";
$w=mysql_query($dat2);
if($w){
echo"成功建立字段id";
}
}
else{
echo"error";
exit;
}
?>
留言簿判断界面,
<?php
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$addr=$_REQUEST['addr'];
$subj=$_REQUEST['subj'];
$contment=$_REQUEST['contment'];
$date=date("Y-m-d H:i:s");
if($name==" "){
echo"你没有输入姓名";
exit();
}
if($email==" "){
echo"你没有输入电子邮件";
exit();
}
//if(!ereg("^[0-9a-zA-Z-]+@([0-9a-zA-Z-]{2,})+/.([a-zA-Z]{2,3})+",$email))
//{
//echo"请你输入一个正确的电子邮件,谢谢!";
//exit();
//}
if($addr==" "){
echo"你没有输入地址";
exit();
}
if($subj==""){
echo"你没有发表主题";
exit();
}
if($contment==""){
echo"你的寄语呢!填一个吧,给同学一个祝福!";
exit();
}
?>
<?php
include("connect.php");
$dd="alter table sub add id int primary key auto_increment";
$query="insert into sub(name,email,addr,subj,contment,time) values('$name','$email','$addr','$subj','$contment',sysdate())";
$result=mysql_query("$query");
echo "留言成功!";
echo "<br><a href=showly.php>查看留言</a>";
?>
<html>
<head>
<title></title></head>
<body topmarqin="2" align="center">
<table width="100%" border=1>
<table border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="#E5F8F7" bordercolorlight="#c2c2c2" bordercolordark="#ffffff" style="color:rgb(0,128,0)">
<tr>
<td width="20%" align="center">
<?php
$day=date("Y年m月d日");
print "$day ";
switch(date("D"))
{
case "Mon":echo"星期一";
break;
case "Tue":echo"星期二";
break;
case "Wen":echo"星期三";
break;
case "Thu":echo"星期四";
break;
case "Fri":echo"星期五";
break;
case "Sat":echo"星期六";
break;
default:echo"星期日";
break;
}
?></td>
<td width="8%" align="center"><a href="index.php">本站首页</a></td>
<td width="15%" align="center"><a href="showly.php">查看留言</a></td>
<td width="15%" align="center"><a href="showqiu.php">查看求职信息</a></td>
<td width="10%" align="center"><a href="luntan.php">本站论坛</a></td>
<td width="10%" align="center"><a href="net.php">网络互联</a></td>
<td width="10%" align="center"><a href="yele.php">娱乐新闻</a></td>
</tr>
</table>
<hr width="100%" size=1>
<form method="post" action="checkly.php" name="form1">
<table border="1" width="100%" bordercolorlight="#c0c0c0" cellspacing="0"cellpadding="0" bordercolordark="ffffff" bgcolor="#E5F8F7" background="../ground/*.jpg" style="color:rgb(0,128,0)">
<tr>
<td width="40%" align="right">
姓 名:</td>
<td width="60%">
<input type="text" name="name" size="30">
</td>
</tr>
<tr>
<td width="40%" align="right">
主 题:</d>
<td width="60%">
<input type="text" name="subj" size="30">
</td>
</tr>
<tr>
<td width="40%" align="right">
邮件地址:</td>
<td width="60%">
<input type="text" name="email" size="30">
</td>
</tr>
<td width="40%" align="right">
家庭住址:</td>
<td width="60%">
<input type="text" name="addr" size="30">
</td>
</tr>
<tr>
<td width="40%" align="right">
留言内容:</td>
<td width="60%">
<textarea name="contment" cols="30" rows="6"></textarea>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<? for($i=0;$i<40;$i++)
echo" ";
?>
<input type=submit value=提 交 name=sub>
<input type=reset value=重 填 name=res></td>
</td>
</tr>
</table>
</form>
<table border="1" width="100%" cellspacing="0" cellpadding="0"
bgcolor="#E5F8F7" bordercolorlight="#c2c2c2" bordercolordark="#ffffff" background="" style="color:rgb(0,128,0)">
<tr>
<td align="center" style="font-size:10.5pt">
[作者:Zhou Minghong]
[E_mail:<a href="maikey4561@163.com">maikey4561@163.com</a>]
[QQ:250431233||471882325]
</td>
</tr> </table>
</td>
</tr>
</table>
</body>
</html>
<?php
include"connect.php";
$query="select * from zhaoping";
$result=mysql_query($query);
$rows=mysql_num_rows($result);
$n=0;
?>
<table border=1 width="100%" height="60%" bordercolorlight="#E5F7F8" bordercolordark="#FFFFFF">
<tr bgcolor="#edfgff" valign="middle" style="font-size:10.5pt">
<th width="8%">序号</th>
<th width="12%">作者</th>
<th width="12%">主题</th>
<th width="20%">时间</th>
<th width="20%">公司</th>
</tr>
<?
for($i=0,$j=0;$i<$rows;$i++,$j++)
{
$bg=$j%2?"edfgff":"ebffff";
//$mysql_data_seek($result,$i);
$r=mysql_fetch_array($result);
$id=$r[adm_id];
$writer=$r[writer];
$subj=$r[subj];
$company=$r[company];
$date=$r[time];
echo "<tr bgcolor=$bg align=center style=/"font-size:10.5pt/">";
?>
<td width="8%"><? echo "$id"?></td>
<td width="12%"><? echo "$writer"?></td>
<td width="12%"><? echo "$subj"?></td>
<td width="20%"><? echo "$company"?></td>
<td width="20%"><? echo "$date"?></td>
</tr>
<?php
}
?>
</table>