こんにちは、次のコードがあります。さまざまなフォームと 1 つのハンドラーが電子メールを php に転送することで、データを電子メールに転送する方法について質問があります。
簡単な.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 = "alfared3006@gmail.com";
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/"); ?>