PHP

PHP 送信フォーム getアクセス 防止

【備忘録】

<?php

$company = '';
$name = '';
$mail = '';
$tell = '';
$content = '';

if (count($_POST) > 0) {
    $company = $_POST['company'];
    $name = $_POST['name'];
    $mail = $_POST['mail'];
    $tell = $_POST['tell'];
    $content = $_POST['content'];
}

?>

<!DOCTYPE html>


送信内容

会社名:<?php echo htmlspecialchars($company,ENT_QUOTES,'UTF-8'); ?>


氏名:<?php echo htmlspecialchars($name,ENT_QUOTES,'UTF-8'); ?>


メール:<?php echo htmlspecialchars($mail,ENT_QUOTES,'UTF-8'); ?>


電話番号:<?php echo htmlspecialchars($tell,ENT_QUOTES,'UTF-8'); ?>


内容:<?php echo nl2br(htmlspecialchars($content,ENT_QUOTES,'UTF-8')); ?>