0

私は事前に検索を行いましたが、私が経験している問題を厳密に再現したものはあまり見つかりませんでした。最近、フォーム要素とPHPを使用してフォームをPOSTメソッドに設定しました。メールと残りのフィールドの情報を受信して​​いることを確認できますが、<select>Jqueryの「datepicker」要素はメールに情報を渡していないため、空白として解決されます。

次のようなHTMLコード:

 <form method="POST" action="mail.php" id="contactform" class="centered">
    <fieldset>
      <input type="text" name="first_name" placeholder="First Name" required>
      <div class="controls controls-row">
        <input type="text" name="last_name" placeholder="Last Name" required>
      </div>
      <input type="email" name="email" placeholder="Email Address" required>
      <div class="controls-row">
        <input type="text" id="datepicker" name="check_in" placeholder="Check-in" required> 
      </div>  
      <div class="controls-row">
        <input type="text" id="datepicker2" name="check_out" placeholder="Check-out" required>
      </div>      
      <div class="controls-row">
        <select id="modalselect" name="rooms">
          <option value="0" selected="selected">Number of Rooms</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5+</option>
        </select>  
      </div>
      <div class="controls-row">
        <select id="modalselect" name="people">
          <option value="0" selected="selected">Number of People</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="1">8</option>
          <option value="2">9</option>
          <option value="3">10+</option>
        </select>
      </div>

      <textarea rows="3" name="additional" input class="input-xparge" placeholder="Anything else?" class="span5"></textarea>
    </fieldset>    
  </form>  
</div>

<div class="modal-footer">
  <button type="submit" name="submit" input type="submit" form="contactform" class="btn btn-block btn-large btn-success"  value="submit">Submit</button>

次のようなPHPコード:

<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$check_in = $POST['check_in'];
$check_out = $POST['check_out'];
$rooms = $POST['rooms'];
$occupants = $POST['people'];
$additional = $_POST['additional'];
$from = "From: Babbacombe Hall Mailserver";
$to = "lloyd.rees09@bathspa.ac.uk";
$subject = "New Booking Enquiry";

$body = "First Name: $first_name\n Last Name: $last_name\n Email: $email\n Check In: $check_in\n Check Out: $check_out\n Number of Rooms: $rooms\n Number of Occupants: $occupants\n Additional Information: $additional"; 

if ($_POST['submit']) {
 if (mail ($to, $subject, $body, $from)) { 
     echo '<p>Your message has been sent!</p>';
   } else { 
       echo '<p>Something went wrong, go back and try again!</p>'; 
   }
}

?>

あなたの助けと専門知識は大歓迎です!

4

1 に答える 1

0

これを置き換えます:

$check_in = $POST['check_in'];
$check_out = $POST['check_out'];
$rooms = $POST['rooms'];
$occupants = $POST['people'];

これとともに:

$check_in = $_POST['check_in'];
$check_out = $_POST['check_out'];
$rooms = $_POST['rooms'];
$occupants = $_POST['people'];
于 2013-02-13T16:34:46.310 に答える