Contact form sends empty letters

I have a problem with the contact form on my site! I tried searching the Internet for answers, but I am new to creating this site and, if possible, would appreciate a simple answer. I guess coding is somewhere wrong, but I really would not know where!

Problem - I receive an email after clicking the "Submit" button, but only the subject line is displayed in my inbox and the message, email address or person’s name is not displayed.

Please, help!


Here is the HTML code:

<form action="result.php" method="post">

<input name="Name" class="" type="text" value="Name (Required)" onfocus="if(this.value == 'Name (Required)') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Name (Required)'; }" />

<input name="Email" class="" type="text" value="Email (Required)" onfocus="if(this.value == 'Email (Required)') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Email (Required)'; }" />

<input name="Subject" class="" type="text" value="Subject" onfocus="if(this.value == 'Subject') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Subject'; }" />

<textarea name="Detail" cols="" rows="" onfocus="if(this.value == 'Describe your project in detail...') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Describe your project in detail...'; }">Describe your project in detail...</textarea>

<input type="submit" name="submit" action="submit" value="submit"  class="submitbtn" />
<input type="reset" name="reset" action="reset" value="reset" class="resetbtn" />
</form>

and PHP code:

<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$detail = $_POST['Detail'];
$to = "info@philippamichael.com";
$subject = "Contact Form Submission";
mail ($to, $subject, $detail, "From" . $name);
echo "Thank You. Your Message has been sent.";

?>
+4
source share
3 answers

Yo, , $email , . , - :

<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$detail = $_POST['Detail'];

$to = "info@philippamichael.com";
$subject = "Contact Form Submission";
$message = $detail . "\n\nFrom Name: {$name}";
$message .= "\nFrom Address: {$email}";

mail ($to, $subject, $message , "From: info@philippamichael.com");

echo "Thank You. Your Message has been sent.";

, From, . , .

+3

: http://www.php.net/manual/en/function.mail.php

 bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

4- - _headers, . :

mail ($to, $subject, $detail, "From: " . $name);
+1

... .

$to = "info@philippamichael.com";
$subject = "Contact Form Submission";
$message = $detail;
$headers = "From: ".$name;
$headers .= "\r\nMIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;\r\n";
mail($to,$subject,$message,$headers);

.

0

Source: https://habr.com/ru/post/1547934/


All Articles