수신 한 전자 메일에는 전자 메일 주소 나 전화 번호 또는 이름이 아닌 메시지 만 표시됩니다.내 HTML 양식은 PHP 메일에 1 개의 값만을 반환합니다.
이메일이 전송 된 메일도 표시되지 않습니다.
양식에서 전체 정보를 받아야합니다. 그렇지 않으면 내게 메시지가 표시되지 않습니다.
누군가이 코드보다 더 간단한 코드를 가지고있을 수 있습니까?
시도했지만 막혔습니다.
누군가 나를 도울 수 있습니까? 다음은
은 HTML과 PHP 코드를입니다HTML 코드 :
<form name="mail" action="mail.php" method="post" >
<div class="form-group ">
<input id="name" class="form-control" placeholder="Name" type="text" required>
<label for="name" class="sr-only">Name</label>
</div>
<div class="form-group ">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control" placeholder="Email" type="email" required>
</div>
<div class="form-group ">
<label for="phone" class="sr-only">Phone</label>
<input id="phone" class="form-control" placeholder="Phone" type="text" required>
</div>
<div class="form-group ">
<label for="message" class="sr-only">Message</label>
<textarea name="message" id="message" cols="30" rows="5" class="form-control" placeholder="Message" required></textarea>
</div>
<div class="form-group ">
<input class="btn btn-primary btn-lg" value="Send Message" name="submit" type="submit">
</div>
</div>
</form>
PHP 코드 : 당신은 다른에 대한 name
속성을 사용할 필요가
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$email_from = "$email";//<== update the email address
$email_subject = "New Form submission";
$email_phone = $phone;
$email_body = "You have received a new message from the user ".$name.
"\nHere is the message:\n ".$message.
"\nThe phone number:\n ".$phone.
"The email:\n ".$email.
$to = "[email protected]";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: index.html');
?>
UR은 메시지 필드에 NAME 속성을 사용하기 때문에' name = "message"' – devpro