http://tetra-themes.com/bootstrap3-php-mailform-327/
上記サイトを参考に、メールフォームの作成を行っています。
フォーム画面は問題なく作成できたのですが、「確認」ボタンを押下した際のPOSTデータが下記となり、末尾に [0]=> string(0) "" といった予期しないデータが含まれてしまいます。
array(6) { ["ご用件"]=> string(0) "" ["お名前"]=> string(0) "" ["電話番号"]=> string(0) "" ["Email"]=> string(0) "" ["お問い合わせ内容"]=> string(0) "" [0]=> string(0) "" }
原因はどこの箇所にあるかお教えください。
・Google Chrome バージョン: 60.0.3112.78(Official Build) (64 ビット)
・IE11
上記2ブラウザ共同じ事象となっています。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>サンプル</title> <meta name="Description" content="" /> <meta name="Keywords" content="" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> #formWrap { width:700px; margin:0 auto; color:#555; line-height:120%; font-size:90%; } table.formTable{ width:100%; margin:0 auto; border-collapse:collapse; } table.formTable td,table.formTable th{ border:1px solid #ccc; padding:10px; } table.formTable th{ width:30%; font-weight:normal; background:#efefef; text-align:left; } </style> </head> <body> <div id="formWrap"> <h3>お問い合わせ</h3> <p>下記フォームに必要事項を入力後、確認ボタンを押してください。</p> <form method="post" action="mail"> <table class="formTable"> <tr> <th>ご用件</th> <td><select name="ご用件"> <option value="">選択してください</option> <option value="ご質問・お問い合わせ">ご質問・お問い合わせ</option> <option value="リンクについて">リンクについて</option> </select></td> </tr> <tr> <th>お名前</th> <td><input size="20" type="text" name="お名前" /> ※必須</td> </tr> <tr> <th>電話番号(半角)</th> <td><input size="30" type="text" name="電話番号" /></td> </tr> <tr> <th>Mail(半角)</th> <td><input size="30" type="text" name="Email" /> ※必須</td> </tr> <tr> <th>性別</th> <td><input type="radio" name="性別" value="男" /> 男 <input type="radio" name="性別" value="女" /> 女 </td> </tr> <tr> <th>サイトを知ったきっかけ</th> <td><input name="サイトを知ったきっかけ[]" type="checkbox" value="友人・知人" /> 友人・知人 <input name="サイトを知ったきっかけ[]" type="checkbox" value="検索エンジン" /> 検索エンジン</td> </tr> <tr> <th>お問い合わせ内容<br /></th> <td><textarea name="お問い合わせ内容" cols="50" rows="5"></textarea></td> </tr> </table> <p align="center"> <input type="submit" value=" 確認 " /> <input type="reset" value="リセット" /> </p> </form> </div> </body> </html>
Choromeのデベロッパーツールでは下記が出力されました。
■Form Data
ご用件:ご質問・お問い合わせ
お名前:test
電話番号:090-1234-5678
Email:test@test.com
性別:男
サイトを知ったきっかけ[]:友人・知人
お問い合わせ内容:test
■Previewタブ
array(8) {
["ご用件"]=>
string(30) "ご質問・お問い合わせ"
["お名前"]=>
string(4) "test"
["電話番号"]=>
string(13) "090-1234-5678"
["Email"]=>
string(13) "test@test.com"
["性別"]=>
string(3) "男"
["サイトを知ったきっかけ"]=>
array(1) {
[0]=>
string(15) "友人・知人"
}
["お問い合わせ内容"]=>
string(4) "test"
[0]=>
string(4) "test"
}
回答4件
あなたの回答
tips
プレビュー