0
我有一個可用的php聯繫表單,但是當它發送消息時,文本區域中沒有空格。我是一個PHP新手,所以我不知道發生了什麼。我試圖尋找答案,但在這裏沒有看到任何東西。有想法該怎麼解決這個嗎?如何向我的php聯繫表格文本區域添加空格
<?php
$name = $_POST["name"];
$email= $_POST["email"];
$message = $_POST["message"];
//error message
$missingName = "<p>Please enter your name.</p>";
$missingEmail ="<p>Please enter your email address.</p>";
$invalidEmail = "<p>Please enter a valid email address.</p>";
$missingMessage = "<p>Please enter a message.</p>";
if($_POST["submit"]){
if(!$name){
$errors .= $missingName;
}else{
$name=filter_var($name, FILTER_SANITIZE_STRING);
}
if(!$email){
$errors .= $missingEmail;
}else{
$email=filter_var($email, FILTER_SANITIZE_EMAIL);
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errors.=$invalidEmail;
}
}
if(!$message){
$errors.= $missingMessage;
}else{
$message= filter_var($message, FILTER_SANITIZE_EMAIL);
}
if($errors){
$resultMessage= '<div class= "alert alert-danger">' . $errors . '</div>';
} else{
$to= "[email protected]";
$subject= "Inquiry";
$message=
"<p>Name: $name</p>
<p>Email: $email</p>
<p>Message:</p>
<p>$message</p>";
$headers = "Content-type: text/html";
if (mail($to, $subject, $message, $headers)){
$resultMessage = '<div class="alert alert-success">Thanks for your interest. We will get back to you as soon as possible.</div>';
}else{
$resultMessage ='<div class="alert alert-warning">Unable to send Email. Please try again later.</div>';
}
}
}
?>
/thanks.php代碼/ $ finalmessage =「姓名:
另外這是 – searching4answers