お世話になります。
セッションを利用して、「ご選択カラー」のチェックボックスの複数項目を呼び出したいです。
いろいろ試してみたのですが、
下記では、確認画面で「array」と表示されてしまいます。
◆入力ファイル(index.php)
php
1<?php session_start(); 2 function filter($data) { 3 $data = strip_tags($data); 4 $data = trim(htmlentities($data, ENT_QUOTES, "UTF-8")); 5 if (get_magic_quotes_gpc())$data = stripslashes($data); 6 return $data; 7 } 8 9 if(isset($_POST['submit'])){ 10 11 $name = ((isset($_POST['name']))?$_POST['name']:""); 12 $_SESSION['entry']['name']= $name; 13 14 15 $email = ((isset($_POST['email']))?$_POST['email']:""); 16 $_SESSION['entry']['email']= $email; 17 18 $content = ((isset($_POST['content']))?$_POST['content']:""); 19 $_SESSION['entry']['content']= $content; 20 21 echo "<script> window.location.href='confirm.php'; </script>"; 22 23 } 24?> 25 26 27 28 <form method="post" action="" id="form_area" > 29 <table cellpadding="0" cellspacing="0" style="width: 100%"> 30 31 <tr> 32 <td> メールアドレス 33 <font color="red">(必須)</font></td> 34 <td><input type="text" name="email" size="50" style="ime-mode:disabled" required /></td> 35 </tr> 36 <tr> 37 <td> 選択カラー 38 <font color="red">(必須)</font></td> 39 <td> 40 <table border="0"> 41 <tr> 42 <td ><label> 43 <input type="checkbox" name="content[]" value="赤" /> 44 赤</label></td> 45 </tr> 46 <tr> 47 <td ><label> 48 <input type="checkbox" name="content[]" value="青" /> 49 青</label></td> 50 </tr> 51 <tr> 52 <td ><label> 53 <input type="checkbox" name="content[]" value="黄" /> 54 黄</label></td> 55 </tr> 56 </table> 57 58 </td> 59 </tr> 60 </table></td> 61 </tr> 62 </table> 63 <br> 64 <p style="text-align: center"> 65 <input type="submit" value="" name="submit" class="submit hover" style="opacity: 1;border: none;"> 66 67 </p> 68 </form> 69
◆確認画面ファイル(confirm.php)
php
1<?php session_start(); 2if(!isset($_SESSION['entry']) && $_SESSION['entry']['email']=="") 3 { 4 echo "<script> window.location.href='index.php'; </script>"; 5 } 6if(isset($_POST['confirm'])) { 7 $to = $_SESSION['entry']['email']; 8 $from_addr = 'info@hoge.jp'; 9(省略) 10 11 12 13 if($_SESSION['entry']['email']) { 14 $message .= 'メールアドレス: '.$_SESSION['entry']['email']."\n"; 15 } 16 17 if($_POST['entry']['content']) { 18 $message .= 'ご選択カラー: '.$_POST['entry']['content']."\n"; 19 } 20 21 (省略) 22 } 23 } 24?> 25 26 27 28 <form method="post" action="" > 29 <table cellpadding="0" cellspacing="0" style="width: 100%"> 30 <tr> 31 <td style="padding:0px;margin:0px;"><table cellpadding="0" cellspacing="0" class="contactTable"> 32 33 <tr> 34 <td> メールアドレス <font color="red">(必須)</font></td> 35 <td><?php echo $_SESSION['entry']['email'];?></td> 36 </tr> 37 <tr> 38 <td> ご選択カラー <font color="red">(必須)</font></td> 39 <td> 40<?php echo $_SESSION['entry']['content'];?> 41 </td> 42 </tr> 43 44 </table></td> 45 </tr> 46 </table> 47 <br> 48 <p style="text-align: center"> 49 <button type="submit" name="confirm" class="submit_confirm hover" style="opacity: 1;border: none;"> </button> 50 </p> 51 </form>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/26 17:48