functions.phpの作成
function connectDb() { try { return new PDO(DSN, DB_USER, DB_PASSWORD); } catch (PDOException $e) { echo $e->getMessage(); exit; } }
function h($s) { return htmlspecialchars($s, ENT_QUOTES, "UTF-8"); }
問合せページの作成 [index.php]
<?php require_once('config.php'); require_once('functions.php'); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>お問合せフォーム</title> </head> <body> <h1>お問合せフォーム</h1> </body> </html>