0

javascript を使用していくつかのフォーム フィールドを検証しようとしていますが、うまく動作しないようです。名前、電話番号、メッセージなど、いくつかの入力がある単純な html フォームです。

Contact.html

 <form action="sent.php" method="post" id="myform" enctype="multipart/form-data">
  <div id="myform"></div>
  <fieldset class="addingenq">

  <label>Your Name</label>
  <input name="custName" type="text" size="40" >

  <label>Phone Number *</label>
  <input name="custPhone" type="text" size="40" >

  <label>Email Address <em>(Optional)</em></label>
  <input name="custEmail" type="text" size="40" >

  <label>Enquiry type</label>
  <input name="subjectType" type="text" size="40"  >

  <label>Details about Enquiry</label>
  <textarea name="messageType" cols="68" rows="5" class="msg" type="text"></textarea>

  <div class="submitbutton">
  <input type="submit" name="submit" value="Submit Message" >
  </div>
  </fieldset>
 </form>

Send.php

contact.html に戻そうとしましたが、電子メールを受信したにもかかわらず、空白の sent.php が表示されました。「custEmail」はこのフォームの要件ではないため、「custEmail」の代わりに $From を custName のようなものにする方法はありますか。

<?php
 if($_POST){
    $custName = $_POST ['custName'];
    $custPhone = $_POST ['custPhone'];
    $custEmail = $_POST ['custEmail'];
    $subjectType = $_POST ['subjectType'];
    $messageType = $_POST ['messageType']; 
  } 
  $subject = "$subjectType";
  $message = "
        Name: $custName \n\n
        Phone Number: $custPhone \n\n
        Enquiry type: $subjectType \n\n
        Message: $messageType \n\n
    ";
  $from = "From: $custEmail\r\n";
  //put your email address here
  mail("myemail@mail.com", $subject, $message, $from);
  exit;             
 ?>
4

2 に答える 2

0

変化する <form action="sent.php" method="post" id="myform" enctype="multipart/form-data">

<form action="sent.php" method="post" id="myform">

if ($_SERVER['REQUEST_METHOD'] == 'POST') { だけの代わりに使用します

if($_POST){

次に、を使用して何かを得ているかどうかを確認します

print_r($_POST)

エラーが発生している可能性がありますが、エラーの表示がオフになっているため、ページにエラーが表示されていません。その場合は、

error_reporting(E_ALL); 
ini_set('display_errors', 1);

あなたのsend.phpページの上に

于 2013-11-06T04:47:23.383 に答える