2013-07-09 2 views
0

Привет, У меня есть следующий код, у меня есть вопрос, как я передаю данные на электронную почту, через различные формы и один обработчик tranfer E-mail на php?

brief.phpКак отправить/отправить несколько данных формы электронной почты

<!-- http://codepen.io/shaligramk/pen/sKCJI --> 
    <div id="pt-main" class="pt-perspective"> 
     <div class="pt-page pt-page-1"> 
      <form method="post" action="send_form_email.php" accept-charset="UTF-8"> 
       //data 
      </form> 
     </div> 
     <div class="pt-page pt-page-2"> 
      <form method="post" action="send_form_email.php" accept-charset="UTF-8"> 
       //data 
      </form> 
     </div> 
     <div class="pt-page pt-page-3"> 
      <form method="post" action="send_form_email.php" accept-charset="UTF-8"> 
       //data  
      </form> 
     </div> 


     <div class="pt-page pt-page-4"> 
      <form method="post" action="send_form_email.php" accept-charset="UTF-8"> 
       /data 
      </form> 
     </div> 
    </div> 

<b><i>send_form_email.php</i></b> 

<?php 

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

    // EDIT THE 2 LINES BELOW AS REQUIRED 

    $email_to = "[email protected]"; 

    function died($error) { 
     // your error code can go here 
     echo "We are very sorry, but there were error(s) found with the form you submitted. "; 
     echo "These errors appear below.<br /><br />"; 
     echo $error."<br /><br />"; 
     echo "Please go back and fix these errors.<br /><br />"; 
     die(); 
    } 

    // validation expected data exists 
    if(!isset($_POST['first_site']) || 
     !isset($_POST['first_site_functions'])|| 
     !isset($_POST['name_surname']) || 
     !isset($_POST['domen_hosting_yes'])){ 
     died('We are sorry, but there appears to be a problem with the form you submitted.'); 
    } 

    // FIRST SLIDE 
    $first_site = $_POST['first_site']; // required 
    $first_site_functions= $_POST['first_site_functions']; // not required 
    $name_surname = $_POST['name_surname']; 

    // SECOND SLIDE 
    $domen_hosting_yes = $_POST['domen_hosting_yes']; 

    if(strlen($error_message) > 0) { 
     died($error_message); 
    } 
    $email_message = "Form details below.\n\n"; 

    function clean_string($string) { 
     $bad = array("content-type","bcc:","to:","cc:","href"); 
     return str_replace($bad,"",$string); 
    } 


    $email_message .="</body></html>"; 
    $email_message .="<h4>".clean_string($name_surname) . " хочет создать сайт!</h4>"; 

     $email_message .="<table style=' display:table; 
        margin-left:auto; 
        margin-right:auto; 
        border-collapse: collapse;'>"; 


       $email_message .="<tbody>"; 
         $email_message .="<tr style='border:1px solid #c6c9cc;padding:12px;'>"; 
           $email_message .= "<td style=' border:1px solid #c6c9cc; 
        padding:12px;'>".clean_string($first_site)."</td>"; 
           $email_message .= "<td style='style=' border:1px solid #c6c9cc; 
        padding:12px;''>".clean_string($first_site_functions)."</td>"; 
           $email_message .= "<td style='style=' border:1px solid #c6c9cc; 
        padding:12px;''>".clean_string($domen_hosting_yes)."</td>"; 
         $email_message .="</tr>"; 
       $email_message .="</tbody>"; 

     $email_message .= "</table>"; 
     $email_message .="</body></html>"; 
// $email_message .= "Comments: ".clean_string($comments)."\n"; 
// create email headers 
     $email_subject = " Пользователь ".clean_string($name_surname) ." хочет создать свой сайт"; 
     $headers = 'From: '.$email_from."\r\n". 
     $headers .= 'Reply-To: '.$email_from."\r\n" . 
     $headers = 'MIME-Version: 1.0' . "\r\n"; 
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
     $headers .= 'X-Mailer: PHP/' . phpversion(); 
     echo (int) mail($email_to, $email_subject, $email_message, $headers); 
    ?>`code` 
    <!-- include your own success html here --> 
    <?php header("Location:http://s-group.in.ua/"); ?> 

ответ

0

Вы можете оставить одну форму в момент.

вы можете использовать форму массива вары в форме, так что наш код должен выглядеть следующим образом

<form method="post" action="send_form_email.php" accept-charset="UTF-8"> 
    <div id="pt-main" class="pt-perspective"> 
     <div class="pt-page pt-page-1"> 

       <input tyupe="text" name="yourSitesNames[]" /> 
       //data 

     </div> 
     <div class="pt-page pt-page-2"> 

       <input tyupe="text" name="yourSitesNames[]" />    
       //data 

     </div> 
     <div class="pt-page pt-page-3"> 

       //data 
      <input tyupe="text" name="yourSitesNames[]" /> 

     </div> 


     <div class="pt-page pt-page-4"> 

       //data 
      <input tyupe="text" name="yourSitesNames[]" /> 

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

вы можете получить доступ к thhese ВАР в PHP:

$_POST['yourSitesNames'][0]; 
$_POST['yourSitesNames'][1]; 
$_POST['yourSitesNames'][2]; 

и т.д ...

+0

'code' $ ('# send_data_button'). bind ('click', function() {$. ajax ({type: "POST", url: "send_form_email.php", data: $ ('input [type = " text "] ')})};'/code 'Я думаю, что это код ответа в моем вопросе – alfared

Смежные вопросы