一、佈景
二、轉向
#轉向頁面
$_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']="";
<{if $redirect}>
<{include file="file:$redirectFile"}>
<{/if}>
###############################################################################
# 轉向函數
###############################################################################
function redirect_header($url = "", $time = 3000, $message = '已轉向!!') {
$_SESSION['redirect'] = "\$.jGrowl('{$message}', { life:{$time} , position: 'center', speed: 'slow' });";
header("location:{$url}");
exit;
}
redirect_header("轉向網址", 停留豪秒, '轉向訊息');
redirect_header("index.php?op=xxx", 3000, '已轉向!!');
exit;
三、連結資料庫
#引入資料庫設定 require_once WEB_PATH.'/sqlConfig.php';
<?php require_once '../../sqlConfig.php';
<?php
if($_SERVER["SERVER_NAME"] == "localhost" or $_SERVER["SERVER_NAME"] == "127.0.0.1"){
#判斷主機為UniServerZ
#MYSQL
#資料庫伺服器
$db_host = "localhost";
#資料庫使用者帳號
$db_user = "root";
#資料庫使用者密碼
$db_password = "111111";
#資料庫名稱
$db_name = "web";
}else{
#MYSQL
#資料庫伺服器
$db_host = "localhost";
#資料庫使用者帳號
$db_user = "user";
#資料庫使用者密碼
$db_password = "password";
#資料庫名稱
$db_name = "db";
}
#PHP 5.2.9以後
$db = new mysqli($db_host, $db_user, $db_password, $db_name);
if ($db->connect_error) {
die('無法連上資料庫 (' . $db->connect_errno . ') '
. $db->connect_error);
}
#設定資料庫語系
$db->set_charset("utf8");
四、在cpanel 建立資料庫
五、整理好的專案目錄
<?php require_once '../../sqlConfig.php';./ :代表本層目錄
六、將專案目錄上傳,記得也要將UniServerZ/sqlConfig.php 資料庫設定檔上傳至 public_html/sqlConfig.php