【勉強メモ】PHP⑪〜フォーム6続き2〜
send.php
<?php require_once dirname(__FILE__).'/func.php'; if(!$_SESSION['success']){ header('location:index.php'); exit; } $name = $_SESSION['name']; $email = $_SESSION['email']; $message = $_SESSION['message']; //↓この記述でarrayの中身が無くなって、トップに戻った時何も入っていない状態になる(配列の初期化) $_SESSION = array(); mb_send_mail('nijigen.saikooo1010@gmail.com','お問い合わせメール',$name.$email.$message); ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>メール送信完了</title> <style> a{ text-decoration:none; } </style> </head> <body> <h1>お問い合せ内容の送信が完了しました。</h1> <p>送信が完了しました。お問い合わせありがとうございました。</p> <table> <tr> <th>お名前:</th><td><?php echo h($name); ?></td> </tr> <tr> <th>Eメール:</th><td><?php echo h($email); ?></td> </tr> <tr> <th>お問い合わせ:</th><td><?php echo nl2br(h($message)); ?></td> </tr> </table> <p><a href="index.php">トップに戻る</a></p> </body> </html>