PHP開發(fā)簡(jiǎn)單圖書借閱系統(tǒng)之創(chuàng)建公共網(wǎng)頁(yè)
在我們這個(gè)借閱系統(tǒng)中頭部的HTML是固定不變的
不隨著頁(yè)面的跳轉(zhuǎn)而變動(dòng)。
為了不重復(fù)的編寫頭部代碼,我們需要制作一個(gè)head.php文件
寫入頭部HTML代碼,以方便在各個(gè)文件中調(diào)用。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <table width="" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" > <tr> <td bgcolor="#FFFFFF"><img src="https://img.php.cn/upload/course/000/000/008/58215f071f35b180.jpg" width="440" height="200" /></td> </tr> <tr> <td bgcolor="#FFFFFF"><table width="440" height="50" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php" title="首頁(yè)">首頁(yè)</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php?proid=<?php echo urlencode('網(wǎng)頁(yè)美工');?>" title="網(wǎng)頁(yè)美工">網(wǎng)頁(yè)美工</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php?proid=<?php echo urlencode('大數(shù)據(jù)');?>" title="大數(shù)據(jù)">大數(shù)據(jù)</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php?proid=<?php echo urlencode('asp編程');?>" title="asp編程">asp編程</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php?proid=<?php echo urlencode('php編程');?>" title="php編程">php編程</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="index.php?proid=<?php echo urlencode('軟件開發(fā)');?>" title="軟件開發(fā)">軟件開發(fā)</a></td> <td align="center" background="https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="landing.php" title="用戶登陸">用戶登陸</a> </td> </tr> </table></td> </tr> </table>
這里把用戶的退出登錄功能也加入其中:
<td align="center" background = "https://img.php.cn/upload/course/000/000/008/58215f29827c0755.jpg"> <a href="landing.php" title="用戶登陸">用戶登陸</a> <?php if ($_SESSION['id']){ echo "<a href='landing.php?tj=out' title='退出'>退出</a>"; } ?> </td>
在登錄功能頁(yè)面進(jìn)行判斷
<?php //初始化session if(isset($_GET['tj']) == 'out'){ session_destroy(); echo "<script language=javascript>alert('退出成功!');window.location='landing.php'</script>"; } ?>