Я создал контактную форму. Когда я заполню все и нажмите «Отправить», а затем перейдите на мою электронную почту в gmail. Весь раздел пуст. Пример того, что я получаю:
Name: Email: Subject: Message:
Вот мой html-код:
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form"> <div class="row"> <div class="col-sm-5"> <div class="form-group"> <input type="text" name="FirstName" id="FirstName" class="form-control" required="required" placeholder="First Name"> </div> <div class="form-group"> <input type="text" name="LastName" id="LastName" class="form-control" required="required" placeholder="Last Name"> </div> <div class="form-group"> <input type="text" name="Emailaddress" id="Emailaddress" class="form-control" required="required" placeholder="Email address"> </div> <div class="form-group"> <button type="submit" class="btn btn-primary btn-lg">Send Message</button> </div> </div> <div class="col-sm-7"> <textarea name="Message" id="Message" required="required" class="form-control" rows="8" placeholder="Message"></textarea> </div> </div> </form>
Вот мой php-код:
header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Email sent!' ); $FirstName = trim(stripslashes($_POST['FirstName'])); echo "Found Firstname: " . $FirstName; $LastName = trim(stripslashes($_POST['LastName'])); echo "Found LastName: " . $LastName; $Emailaddress = trim(stripslashes($_POST['Emailaddress'])); echo "Found Emailaddress: " . $Emailaddress; $subject = 'This is the subject'; echo "Found subject: " . $subject; $Message = trim(stripslashes($_POST['Message'])); echo "Message: " . $Message; $email_from = $Emailaddress; $email_to = 'karolburatynski@gmail.com'; $body = 'Name: ' . $FirstName . "\n\n" . 'Email: ' . $Emailaddress . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $Message; $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>'); echo json_encode($status); die;