PHP-フォーム1
お問い合わせ入力フォーム1
index.php
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>お問い合わせフォーム</title> <link rel="stylesheet" href="style.css" media="screen, print"> </head> <body> <form action="check.php" method="post" id="inquiry"> <table summary="お問い合わせに関する入力項目名とその入力欄"> <tr> <th><label for="name">お名前</label></th> <td><input type="text" name="name" size="30" id="name" class="text1"></td> </tr> <tr> <th><label for="email">メールアドレス</label></th> <td><input type="text" name="email" size="30" id="email" class="text2"></td> </tr> <tr> <th><label for="message">ご意見</label></th> <td><textarea name="message" cols="30" rows="5" class="text3" id="message"></textarea></td> </tr> </table> <input type="submit" value="確認画面へ"> </form> </body> </html>
check.php
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>確認画面</title> <link rel="stylesheet" href="style.css" media="screen, print"> </head> <body> <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; if($name=='') { print 'お名前が入力されていません。<br>'."\n"; }else{ print'ようこそ、'.$name.'様<br>'."\n"; } if($email=='') { echo'メールアドレスが、入力されていません。<br>'."\n"; } else { echo'メールアドレス: '.$email.'<br>'."\n"; } if($message=='') { echo 'お問い合わせの内容が、入力されていません。'. "\n"; } else { echo 'お問い合わせ内容: '.$message."\n"; } ?> </body> </html>
style.css
@charset "UTF-8"; body { font-size: 1.0em; font-family: sans-serif; line-height: 1.5; color: #333333; background-color: #ffffff; } #inquiry { width: 600px;/*ボックス幅の指定*/ padding: 2px 0 2px 20px; border-left: 5px #3CC solid; } th { text-align: right; }