2017-02-13 18 views
1

私は同じページに3つのphpメール送信フォームを持っています。私が最初のフォームに記入して提出すると、他の2名も提出され、空の価値があり、メールをメールに送信します。3つのphpは同じページにメールフォームを送信します。最初に送信する3つのメールすべてを送信します

3つのメールフォームはすべて異なるメールアドレスでメールを送信する必要があります。この問題を解決するのを手伝ってください。

最初のフォームをクリックすると、最初のフォームのみが電子メールを送信し、エコーを出力するはずです。しかし、ここではすべてのエコープリントとすべてのメールが一度に送信されます。

<?php 
if(isset($_POST['submit'])){ 
$to = "[email protected]"; // this is your Email address 
$from = $_POST['o_email']; // this is the sender's Email address 

$o_email = $_POST['o_email']; 

$o_address = $_POST['o_address']; 

$subject = "buy alert from aluta"; 
//$subject2 = "Copy of your from Aluta"; 
$message =" Hi, admin, you have an message from OFFICE \n\r Message: ". $o_address ." \n\rProduct link: \n\n" . $_POST['message']; 
// $message2 = "Here is a copy of your message " . $s_name . "\n\n" . $_POST['message']; 

$headers = "From:" . $from; 
$headers2 = "From:" . $to; 
mail($to,$subject,$message,$headers); 
//mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender 
echo "<h3>Mail Sent. Thank you " . $s_name . ", You will be contacted now.<h3>"; 
// You can also use header('Location: thank_you.php'); to redirect to another page. 
} 
?> 

<div class="modal fade" id="office" role="dialog"> 
    <div class="modal-dialog modal-md"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal">&times;</button> 
       <h4 class="modal-title">GET UPDATED ON THE DIME</h4> 
      </div> 
      <div class="modal-body"> 
       <form method="post" action="" class="form-horizontal"> 
        <div class="form-group"> 

         <div class="col-sm-12"> 
          <input type="email" class="form-control" name="o_email" placeholder="Enter email"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <div class="col-sm-12"> 
          <textarea type="text" class="form-control" rows="8" name="o_address" placeholder="I'm Intrested in retail space"></textarea> 
         </div> 
        </div> 
        <style> 
        .btn-default { 
         color: #fff; 
         background-color: #080808; 
         border-color: #ccc;} 
         </style> 
         <div class="form-group"> 
          <div class="col-sm-12"> 
           <input type="submit" name="submit" class="btn-block btn btn-default" value="Submit"/> 
          </div> 
         </div> 
        </form> 
       </div> 

      </div> 
     </div> 
    </div> 

    <?php 
    if(isset($_POST['submit'])){ 
$to = "[email protected]"; // this is your Email address 
$from = $_POST['s_email']; // this is the sender's Email address 

$s_email = $_POST['s_email']; 

$s_address = $_POST['s_address']; 

$subject = "buy alert from aluta"; 
//$subject2 = "Copy of your from Aluta"; 
$message =" Hi, admin, you have an message from RESIDENCES \n\r Message: ". $s_address ." \n\rProduct link: \n\n" . $_POST['message']; 
// $message2 = "Here is a copy of your message " . $s_name . "\n\n" . $_POST['message']; 

$headers = "From:" . $from; 
$headers2 = "From:" . $to; 
mail($to,$subject,$message,$headers); 
//mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender 
echo "<h3>Mail Sent. Thank you " . $s_name . ", You will be contacted now.<h3>"; 
// You can also use header('Location: thank_you.php'); to redirect to another page. 
} 
?> 


<div class="modal fade" id="residences" role="dialog"> 
    <div class="modal-dialog modal-md"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal">&times;</button> 
       <h4 class="modal-title">GET UPDATED ON THE DIME</h4> 
      </div> 
      <div class="modal-body"> 
       <form method="post" action="" class="form-horizontal"> 
        <div class="form-group"> 

         <div class="col-sm-12"> 
          <input type="email" class="form-control" name="s_email" placeholder="Enter email"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <div class="col-sm-12"> 
          <textarea type="text" class="form-control" rows="8" name="s_address" placeholder="I'm Intrested in retail space"></textarea> 
         </div> 
        </div> 

        <div class="form-group"> 
         <div class="col-sm-12"> 
          <input type="submit" name="submit" class="btn-block btn btn-default" value="Submit"/> 
         </div> 
        </div> 
       </form> 
      </div> 

     </div> 
    </div> 
</div> 



<?php 
if(isset($_POST['submit'])){ 
$to = "[email protected]"; // this is your Email address 
$from = $_POST['r_email']; // this is the sender's Email address 

$r_email = $_POST['r_email']; 

$r_address = $_POST['r_address']; 

$subject = "buy alert from aluta"; 
//$subject2 = "Copy of your from Aluta"; 
$message =" Hi, admin, you have an message from OFFICE \n\r Message: ". $r_address ." \n\rProduct link: \n\n" . $_POST['message']; 
// $message2 = "Here is a copy of your message " . $s_name . "\n\n" . $_POST['message']; 

$headers = "From:" . $from; 
$headers2 = "From:" . $to; 
mail($to,$subject,$message,$headers); 
//mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender 
echo "<h3>Mail Sent. Thank you " . $s_name . ", You will be contacted now.<h3>"; 
// You can also use header('Location: thank_you.php'); to redirect to another page. 
} 
?> 
<div class="modal fade" id="retail" role="dialog"> 
    <div class="modal-dialog modal-md"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal">&times;</button> 
       <h4 class="modal-title">GET UPDATED ON THE DIME</h4> 
      </div> 
      <div class="modal-body"> 
       <form method="post" action="" class="form-horizontal"> 
        <div class="form-group"> 

         <div class="col-sm-12"> 
          <input type="email" class="form-control" name="r_email" placeholder="Enter email"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <div class="col-sm-12"> 
          <textarea type="text" class="form-control" rows="8" name="r_address" placeholder="I'm Intrested in retail space"></textarea> 
         </div> 
        </div> 

        <div class="form-group"> 
         <div class="col-sm-12"> 
          <input type="submit" name="submit" class="btn-block btn btn-default" value="Submit"/> 
         </div> 
        </div> 
       </form> 
      </div> 

     </div> 
    </div> 
</div> 

答えて

0
<input type="submit" name="submit" class="btn-block btn btn-default" value="Submit"/> 

if(isset($_POST['submit'])){ 

あなたは、送信ボタンを各フォームに同じ名前を使用しています。各ペアをユニークにします。

<input type="submit" name="submit1" class="btn-block btn btn-default" value="Submit"/> 

if(isset($_POST['submit1'])){ 



<input type="submit" name="submit2" class="btn-block btn btn-default" value="Submit"/> 

if(isset($_POST['submit2'])){ 
+0

ありがとうございます –

関連する問題