Имеется HTML разметка
<form method="post" id="fsave" action="">
<label>
<input type="text" name="name" required="required" maxlength="70" id="name" placeholder="Имя*"/>
</label>
<label>
<input type="text" name="phone" required="required" maxlength="70" id="phone" placeholder="Телефон*"/>
</label>
<label>
<input type="text" name="subject" required="required" maxlength="150" id="subject" placeholder="E-mail*"/>
</label>
<label><textarea name="message" class="msgforadmin" placeholder="Расскажите, что Вас интересует ✎"></textarea>
</label>
<p><button id='sender' class="button" type="submit">Отправить</button></p>
</div>
</form>
И PHP код
<?php
if ($_POST) {
$email = '[email protected]';
$name = htmlspecialchars($_POST["name"]);
$subject = htmlspecialchars($_POST["subject"]);
$message = htmlspecialchars($_POST["message"]);
$phone = htmlspecialchars($_POST["phone"]);
$json = array();
if (!$phone or !name or !$subject or !$message) {
$json['error'] = 'Вы зaпoлнили нe всe пoля';
echo json_encode($json);
die();
}
function mime_header_encode($str, $data_charset, $send_charset) {
if($data_charset != $send_charset)
$str=iconv($data_charset,$send_charset.'//IGNORE',$str);
return ('=?'.$send_charset.'?B?'.base64_encode($str).'?=');
}
class TEmail {
public $from_email;
public $from_name;
public $to_email;
public $to_name;
public $subject;
public $data_charset='UTF-8';
public $send_charset='windows-1251';
public $body='';
public $type='text/plain';
function send(){
$dc=$this->data_charset;
$sc=$this->send_charset;
$enc_to=mime_header_encode($this->to_name,$dc,$sc).' <'.$this->to_email.'>';
$enc_subject=mime_header_encode($this->subject,$dc,$sc);
$enc_from=mime_header_encode($this->from_name,$dc,$sc).' <'.$this->from_email.'>';
$enc_body=$dc==$sc?$this->body:iconv($dc,$sc.'//IGNORE',$this->body);
$headers='';
$headers.="Mime-Version: 1.0\r\n";
$headers.="Content-type: ".$this->type."; charset=".$sc."\r\n";
$headers.="From: ".$enc_from."\r\n";
return mail($enc_to,$enc_subject,$enc_body,$headers);
}
}
$emailgo= new TEmail;
$emailgo->from_name= $phone;
$emailgo->to_email= $email;
$emailgo->body= $name;
$emailgo->from_email= '[email protected]';
$emailgo->subject= $subject;
$emailgo->body= $message;
$emailgo->send();
$json['error'] = 0;
echo json_encode($json);} else { echo 'GET LOST!';}?>
Задача: значение из тега с name="message"
и из тега с name="subject"
должны оказаться в поле body
нашего сообщения в порядке их ввода. Т.е. сперва e-mail, а ниже - остальной текст сообщения введенный через name=message
В PHP не особо силен. Как мне решить эту задачу?