-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
36 lines (31 loc) · 862 Bytes
/
functions.php
File metadata and controls
36 lines (31 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
//共通で使うものを別ファイルにしておきましょう。
//DB接続関数(PDO)
function db_con(){
try {
$pdo = new PDO('mysql:dbname=design_db;charset=utf8;host=localhost','root','');
return $pdo;
} catch (PDOException $e) {
exit('データベースに接続できませんでした。'.$e->getMessage());
}
}
//SQL処理エラー
function err_db_Info($stmt){
$error = $stmt->errorInfo();
exit("ErrorQuery:".$error[2]);
}
//XSS:htmlspecialchars
function h($str){
return htmlspecialchars($str);
}
// SESSION Check
function chkSsid(){
if( !isset($_SESSION["chk_ssid"]) || $_SESSION["chk_ssid"]!=session_id()){
// exit("Login...");
header("Location: login.php");
}else{
session_regenerate_id(true);
$_SESSION["chk_ssid"]=session_id();
}
}
?>