2017-01-08 8 views
-2

私はPHPコーディングの初心者です。私はSalonのウェブサイトで作業しています。サイトには、ユーザーが電子メールを送信する形式で予約を予約できるフォームがあります.HTMLフォームにある複数の選択ボックスから値をPOSTして、そのデータを電子メールの他のフィールド。他のフィールドはPOST POSTが正常です。しかし、選択ボックスは機能しません。以下は私が作業しているコードです:複数の選択ボックスをHTMLフォームで使用する

<?php 
$clnt_name = $_POST['w_p_c_name']; 
$clnt_email = $_POST['w_p_c_email']; 
$clnt_phn_no = $_POST['w_p_c_number']; 
$rsrvtn_date = $_POST['w_p_c_date']; 
$hair_cut = $POST['opt_hair_cut']; 
$colr_whl_hair = $POST['opt_colouring_whole_hair']; 
$colr_retouch = $POST['opt_colouring_retouch_roots']; 
$colr_highlight = $POST['opt_colouring_highlighting']; 
$rebonding = $POST['opt_rebonding']; 
$relax_straight = $POST['opt_relaxing_straightening']; 
$perming = $POST['opt_perming']; 
$threading = $POST['opt_threading']; 
$bleaching = $POST['opt_bleaching']; 
$manicure = $POST['opt_manicure']; 
$pedicure = $POST['opt_pedicure']; 
$nail = $POST['opt_nail']; 
$gel_nail = $POST['opt_gel_nail']; 
$massage = $POST['opt_massage']; 
$scrub = $POST['opt_scrub']; 
$wax_face = $POST['opt_wax_face']; 
$wax_arms = $POST['opt_wax_arms']; 
$wax_leg = $POST['opt_wax_leg']; 
$wax_body = $POST['opt_wax_body']; 
$wax_intimate = $POST['opt_wax_intimate']; 
$makeup = $POST['opt_makeup']; 
$hijab = $POST['opt_hijab']; 
$hairstyle_blodry = $POST['opt_hairstyle_blowdry']; 
$hairstyle_iron = $POST['opt_hairstyle_iron']; 
$hairstyle_spcl = $POST['opt_hairstyle_special']; 
$hair_trmnt = $POST['opt_hair_treatment']; 
$face_cleaning = $POST['opt_face_cleaning']; 
$facials = $POST['opt_facials']; 
$face_trmnt = $POST['opt_face_treatments']; 
$scrub_ladies = $POST['opt_scrubs_ladies']; 
$massage_ladies = $POST['opt_massage_ladies']; 

$data = "Name : ".$clnt_name."\nEmail : ".$clnt_email."\nPhone : ".$clnt_phn_no."\nRequested Date : ".$rsrvtn_date."\nServices Requested :\n\n".$hair_cut."\n".$colr_whl_hair."\n".$colr_retouch."\n".$colr_highlight."\n".$rebonding."\n".$relax_straight."\n".$perming."\n".$threading."\n".$bleaching."\n".$manicure."\n".$pedicure."\n".$nail."\n".$gel_nail."\n".$massage."\n".$scrub."\n".$wax_face."\n".$wax_arms."\n".$wax_leg."\n".$wax_body."\n".$wax_intimate."\n".$makeup."\n".$hijab."\n".$hairstyle_blodry."\n".$hairstyle_iron."\n".$hairstyle_spcl."\n".$hair_trmnt."\n".$face_cleaning."\n".$facials."\n".$face_trmnt."\n".$scrub_ladies."\n".$massage_ladies; 

$file = "services.xlxs"; 

$subject = "Reservation Booking"; 
$mail_message1 = "Hi ".$clnt_name." We have received your request for a reservation with the following details.\n\n".$data."\n\nWe will be calling to confirm the reservation shortly.\n\nThank you"; 

$to_rsvtn = "[email protected]"; 
$subject2 = "Reservation"; 
$mail_message2 = "There has been a new request for a reservation. Details are listed below: \n\n".$data; 


file_put_contents($file, $data1 . PHP_EOL, FILE_APPEND); 
file_put_contents($file, $data2 . PHP_EOL, FILE_APPEND); 
file_put_contents($file, $data3 . PHP_EOL, FILE_APPEND); 

mail($clnt_email, $subject, $mail_message1, "From:" . $to_rsvtn); 
mail($to_rsvtn, $subject2, $mail_message2, "From:" . $to_rsvtn); 
header('Location: ba-complete.html'); 

?> 

何か助けていただければ幸いです。

+1

HTMLコードも投稿できますか? –

+0

チェックボックスがオフの場合、値は送信されません。あなたのサーバは、渡された値に応じてチェックボックスを値にするか空にする必要がありますか? – mplungjan

+0

* "他のフィールドは正常にPOSTされています" * - 私はそれほど信じがたい、多くの '$ POST'が無効であることがわかります。 –

答えて

1

実際にHTMLコードを追加すると役立ちます。

あなたはオプションの配列として$_POST['select']を治療するために、PHPはちょうどこのようselect要素の名前に角括弧を追加したい場合:<select name="select[]" multiple …

次に、あなたがあなたのPHPスクリプトで

を配列アクセスも可能
<?php  
foreach ($_POST['select'] as $selectedOption) { 
    echo $selectedOption."\n"; 
} 
?> 
+0

本当ですが、あなたの答えは、間違った多くの '$ POST'の使用の概要を説明することができませんでした。 –

関連する問題