戻る      mail_input.php      sendmail.php

《PHP言語 /mail_input.php》

<html>
<head>
<title>10日でおぼえるPHP5入門教室(アンケート)</title>
</head>
<body>
<h1 style="background:#cccccc">
10日でおぼえるPHP5入門教室(アンケート)</h1>
<form method="POST" action="sendmail.php">
<input type="hidden" name="_email" value="tateda-yoshio@nifty.com" />
<input type="hidden" name="_subject" value="10日でおぼえるPHP5入門教室" />
<input type="hidden" name="_result"
value="<?php print($_SERVER['PHP_SELF']);?>" />
<table border="0">
<tr>
<th align="right">名前:</th>
<td><input type="text" name="name" size="20" maxlength="30" /></td>
</tr><tr>
<th align="right">E-Mail:</th>
<td><input type="text" name="_from" size="50" maxlength="255" /></td>
</tr><tr>
<th align="right" valign="top">自由記入欄:</th>
<td><textarea name="memo" cols="50" rows="5"></textarea></td>
</tr>
</table>
<input type="submit" value="送信" />
<input type="reset" value="クリア" />
</form>
</body>
</html>

《PHP言語 /sendmail.php》

<?php
$header_info="From: ".$_POST['_from']."\nContent-Type: text/plain;charset=ISO-2022-JP\nX-Mailer: PHP/".phpversion();
$body="■■".$_POST['_subject']."■■\n\n";
foreach($_POST as $key=>$value){
if(!strstr($key,"_")){
$body.="[".$key."]".$value."\r\n";
}
}
mb_send_mail($_POST['_email'],$_POST['_subject'],$body,$header_info);
header("Location: ".$_POST['_result']);
?>