入力フォームまとめ

入力フォームまとめ

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>入力フォームまとめ</title>
</head>
<body>
<div id="confirmation">
<form action="check.php" method="post">
<table>
<tr>
<th><label for="name">お名前</label></th>
<td><input type="text" name="name" id="name" size="30"></td>
</tr>
<tr>
<th><label for="email">メールアドレス</label></th>
<td><input type="text" name="email" id="email" size="30"></td>
</tr>
<tr>
<th><label for="message">ご意見</label></th>
<td><textarea name="message" id="message" cols="30" rows="5"></textarea>
</td>
</tr>

</table>
<input type="submit" value="送信">
</form>
</div>
</body>
</html>

check.php

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>確認画面</title>
</head>
<body>
<?php
$name = htmlspecialchars($_POST['name'],ENT_QUOTES);
$email = htmlspecialchars($_POST['email'],ENT_QUOTES);
$message = htmlspecialchars($_POST['message'],ENT_QUOTES);

print '<ul>'."\n";
print '<li>';
if ($name==''){
  print 'お名前が入力されていません';
}else{
  print 'ようこそ、'.$name.'さま';
}
print '</li>'."\n";

print '<li>';
if($email==''){
print 'メールアドレスが入力されていません';
}else{
print 'メールアドレス:'.$email;
}
print '</li>'."\n";
print '<li>';
if($message==''){
print 'お問い合わせの内容が、入力されていません';
}else{
print 'お問い合わせの内容:'.$message;
}
print '</li>'."\n";
print '</ul>'."\n";

if($name=='' || $email=='' || $message==''){
print '<form>'."\n";
print '<input type="button" onClick="history.back()" value="戻る">'."\n";;
print '</form>'."\n";
}else{
print '<form action="tanks.php" method="post">'."\n";
print '<input type="button" onClick="history.back()" value="戻る">'."\n";
print'<input type="submit" value="送信">'."\n";
print '</form>'."\n";
}
?>
</body>
</html>