《php实训代码.docx》由会员分享,可在线阅读,更多相关《php实训代码.docx(18页珍藏版)》请在金锄头文库上搜索。
1、php实训代码Index.phpbody margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;#1 #zhuye width: 30%;height: 300px;float: none;#Layer1 position:absolute;left:58px;top:300px;width:497px;height:196px;z-index:1;#Layer2 position:absolute;left:631px;top:299px;width:467px;height:192px;z-index:2
2、;a:link text-decoration: none;a:visited text-decoration: none;a:hover text-decoration: none;a:active text-decoration: none;.STYLE1 font-size: 18px;font-family: 新宋体;.STYLE2 font-size: x-small-include news/functions/database.php;include news/functions/page.php;include news/functions/trColor.php; getCo
3、nnection();$page_size=5;if(isset($_GETpage_current)$page_current=$_GETpage_current;else$page_current=1;$start=($page_current-1)*$page_size;if(isset($_GETmessage)echo $keyword=;if(isset($_GETkeyword)$keyword=$_GETkeyword;$sql=select title,news_id from news where title like %$keyword% or content like
4、%$keyword% order by news_id desc;$sqlcount=select count(*) from news where title like %$keyword% or content like %$keyword%;if($keyword=)$sql=select title,news_id,publish_time from news order by news_id desc;$sqlcount=select count(*) from news; $rowcount=mysql_fetch_array(mysql_query($sqlcount);$tot
5、al_records=$rowcount0;$sql.= limit $start,$page_size;$r=mysql_query($sql);closeConnection();if(mysql_num_rows($r)=0)echo 暂时没有记录;else?cellspacing=0while($row=mysql_fetch_array($r)/ $color = trColor();bgcolor=$color?src=426/flog1.jpghref=news/news_detail.php?news_id=$rownews_id ?$rowpublish_time;?incl
6、ude news/functions/islogin.php;if(islogin()echo 欢迎.$_SESSIONname.的到来;echo 注销;else?action=news/login_process.phpalign=center class=STYLE1会员登录用户名:value=$_COOKIEname; ? /密码:id=password /value=登录 取消?width=200 height=200 /width=200 height=200 /width=200 height=200 /width=200 height=200 /width=200 height=
7、200 /href=news/more_list.phpsrc=img/xinwendongtai.gif width=260 height=80border=0 /width=260 height=80 /src=img/zonghexinwen.gif width=260 height=80/href=426/zhuce.htmlsrc=img/huiyuanzhuce.gif width=260 height=80border=0 /href=http:/ http:/ - href=http:/ 网络媒体许可证0110544Register.Php1.0 Transitional/EN
8、http:/ /span font-family: 宋体;font-size: medium;font-weight: bold;color: #FF0000;text-align: center;a:link color: #0033CC;a:active color: #990000;a:visited color: #0033FF;a:hover color: #FF0000;-include_once(H:wampwwwnewsfunctionsdatabase.php);if(isset($_POSTSubmit)$password = $_POSTpassword;$confirm
9、Password = $_POSTconfirmPassword;$userName = $_POSTuserName;if($password != $confirmPassword)exit(target=_self致!注册失败!点此返回$userName = $_POSTuserName;$userNameSQL = select * from users wherename=$userName;getConnection();$resultSet = mysql_query($userNameSQL);if(mysql_num_rows($resultSet)0)exit(target
10、=_self他用户名!点此返回$p=md5(md5($password);$registerSQL = insert into users values(null,$userName,$p);$message =mysql_query($registerSQL);if($message)echo 册! echo target=_selfelseecho echo closeConnection();?Guanli.phpsession_start();?.workfont-size:32px;color:#FF6600;padding-top:180px;body background-col
11、or:=#CCFFFF;.STYLE1 font-size: 18px;font-weight: bold;.formpadding-top:280px;padding-right:50px;padding-left:600px;.STYLE2 -echo 欢迎.$_SESSIONname.的到来!;echo 注销;?Guanli2.php session_start();?Transitional/ENhttp:/ /.workfont-size:32px;color:#FF6600;padding-top:180px;body background-color:=#CCFFFF;.STYL
12、E1 font-size: 18px;font-weight: bold;.formpadding-top:280px;padding-right:50px;padding-left:600px;.STYLE2 -echo 欢迎.$_SESSIONname.的到来!;echo 注销;?Database.phpfunction getConnection()$hostname=localhost;$user=root;$pass=;$dbname=news;mysql_connect($hostname,$user,$pass) or die(连接数据库失败);mysql_query(set names gb2312);mysql_select_db($dbname) or die(选择数据库