#轉向頁面
$_SESSION['redirect']=isset($_SESSION['redirect'])?$_SESSION['redirect']:"";
$redirectFile = WEB_PATH."/class/jGrowl/redirect_header.tpl";
$smarty->assign("redirect", $_SESSION['redirect']);
$smarty->assign("redirectFile", $redirectFile);
$_SESSION['redirect']="";
```
5. theme.tpl ```
<{if $redirect}>
<{include file="file:$redirectFile"}>
<{/if}>
```
6. function.php ```
###############################################################################
# 轉向函數
###############################################################################
function redirect_header($url = "", $time = 3000, $message = '已轉向!!') {
$_SESSION['redirect'] = "\$.jGrowl('{$message}', { life:{$time} , position: 'center', speed: 'slow' });";
header("location:{$url}");
exit;
}
```
7. 使用 ```
redirect_header("轉向網址", 停留豪秒, '轉向訊息');
redirect_header("index.php?op=xxx", 3000, '已轉向!!');
exit;
```
三、連結資料庫
1. head.php ```
#引入資料庫設定
require_once WEB_PATH.'/sqlConfig.php';
```
2. sqlConfig.php ```
connect_error) {
die('無法連上資料庫 (' . $db->connect_errno . ') '
. $db->connect_error);
}
#設定資料庫語系
$db->set_charset("utf8");
```
四、在cpanel 建立資料庫
1. 登入cpanel
2. http://cpanel.帳號.ugm.com.tw/
3. 示範:
![](https://docs.google.com/drawings/d/e/2PACX-1vRSXdbeOgwstoMCq5D8gop_RO-NajNvpRVT_EWrIO7bjiQUvVfk2__GOVF5mjrOEd_IJAQ5RmYL-f2y/pub?w=956&h=746)
4. 在uniserverZ 建資料庫
![](https://docs.google.com/drawings/d/e/2PACX-1vTDf_dN44f_H3jngU_jMsrwvpuX1YxwiyqxbBU5XuuugvnfrDb7ASi0W0Z1gID7ItYzpG1gA9dbPenM/pub?w=880&h=338)
五、整理好的專案目錄
1. [下載](https://github.com/webugm/soft/raw/gh-pages/soft/tncomu10602/web_20170927_1.0.zip)
2. 直接下載至 www/ 解壓縮,再改目錄名稱即可
3. 連結資料庫密碼設定檔 UniServerZ/sqlConfig.php 此檔必須與 專案目錄/sqlConfig.php 對應 ```
sqlConfig.php 資料庫設定檔上傳至 public\_html/sqlConfig.php