联系表单未发送但正在上传文件

问题描述

我有一个联系表,其中包含文件上传。联系人表格位于悬停框中。它附加了文件上传,我在我的文件夹中找到文件,但没有收到电子邮件。有人可以帮我解决这个问题。非常感谢您提供的所有帮助。 我有一个联系表单,其中包含文件上传。联系人表格位于悬停框中。它附加了文件上传,我在文件夹中找到文件,但没有收到电子邮件。有人可以帮我解决这个问题。非常感谢您提供的所有帮助。

<?php

 //Settings
$max_allowed_file_size = 100; // size in KB
$allowed_extensions = array("jpg","jpeg","gif","bmp");
//Validations
if($size_of_uploaded_file > $max_allowed_file_size )
{
  $errors .= "\n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
  if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
  {
    $allowed_ext = true;
  }
}
if(!$allowed_ext)
{
  $errors .= "\n The uploaded file is not supported file type. ".
  " Only the following file types are supported: ".implode(',',$allowed_extensions);
}

  if(!empty($_FILES['uploaded_file']))
  {
    $path = "uploads/";
    $path = $path . basename( $_FILES['uploaded_file']['name']);
   $email_to = "contest@capebretoncares.com";
    $email_subject = "Add my Fur Baby to Cape Breton Cares";
 if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$path)) {
       
header("Location: https://www.capebretoncares.com/p/thank-you-image/");
    } else{
        echo "There was an error uploading the file,please try again!";
    }
  }
  
?>

<?php
if(isset($_POST['email'])) {
 
 
     
 
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $subject = $_POST['subject']; // required
    $uploaded_file = $_FILES['uploaded_file']; // required
    $comments = $_POST['comments']; // required
 
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
 
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.</br>';
  }
 
    $string_exp = "/^[A-Za-z .'-]+$/";
 
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.</br>';
  }
 
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.</br>';
  }
 
 if(!preg_match($string_exp,$subject)) {
    $error_message .= 'The Subject you entered does not appear to be valid.</br>';
  }
  
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.</br>';
  }
 
  if(strlen($error_message) > 0) {
    died($error_message);
  }
 
    $email_message = "Form details below.\n\n";
 
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
 
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Subject: ".clean_string($subject)."\n";
    $email_message .= "Image: ".clean_string($uploaded_file['name'])."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
 
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to,$email_subject,$email_message,$headers);  
?> 
<?php
 
}
?>
.furbc {
cursor: pointer;
}

.toolstip {
display: inline-block;
position: relative;
}

.toolstip .toolstiptext {
background-color: rgba(0,0.36);
border-radius: 5px;
border-top: 4px solid #da291c;
color: #ffffff;
font-family: Netflix Sans,Helvetica,Arial,sans-serif;
font-size: 15px;
font-weight: 400;
left: 50%;
margin-left: -285px;
margin-top: 1px;
opacity: 1;
padding: 10px ;
position: absolute;
text-align: left;
visibility: hidden;
width: 275px;
z-index: 1;
}

.toolstip:hover .toolstiptext {
visibility: visible;
}

.furbcf form {
display: flex;
position: relative;
width: 100%;
}

.furbcf input[type=text] {
border: 1px solid #C2C2C2;
border-radius: 5px;
box-sizing: border-box;
color: #242527; 
font-family: Netflix Sans,sans-serif;
font-size: 15px;
font-weight: 300;
margin: 0px 0px;
padding: 5px 5px;
width: 175px;
}

.furbcf input:focus { 
border: 1px solid #da291c;
border-radius: 5px;
outline: none;
}

.furbcf textarea {
border: 1px solid #C2C2C2;
border-radius: 5px;
box-sizing: border-box;
color: #242527; 
font-family: Netflix Sans,sans-serif;
font-size: 15px;
font-weight: 300;
margin: 0px 0;
padding: 5px 5px;
width: 175px;
}

.furbcf textarea:focus {
border: 1px solid #da291c;
border-radius: 5px;
outline: none;
}

.furbcf input[type="submit"] {
background-color: #ffffff;  
border: 2px solid #da291c;   
border-radius: 5px;
box-sizing: border-box; 
color: #da291c; 
cursor: pointer;
font-family: Netflix Sans,sans-serif;
font-size: 15px;
font-weight: 300; 
outline: none;
padding: 5px;  
width: 100px;   
}

.furbcf input[type="submit"]:hover {
background-color: #da291c;    
border: 2px solid #da291c; 
border-radius: 5px;
box-sizing: border-box; 
color: #ffffff;  
cursor: pointer;
font-family: Netflix Sans,sans-serif;
font-size: 15px;
font-weight: 300;
padding: 5px;    
width: 100px;
}
<form class="furbcf" method="post" action="send_contact.php" enctype="multipart/form-data">
<label for="first_name">First Name: <font color="red">*</font></label>
</br>
<input type="text" id="first_name" name="first_name" autocomplete="off" required>
</br>
</br>
<label for="last_name">Fur Babies Name: <font color="red">*</font></label>
</br>
<input type="text" id="last_name" name="last_name" autocomplete="off" required>
</br>
</br>
<label for="email">Email: <font color="red">*</font></label>
</br>
<input type="text" id="email" name="email" autocomplete="off" required>
</br>
</br>
<input type="file" name="uploaded_file"autocomplete="off" required>
</br>
</br>
<input type="submit" name="Submit" value="Submit">
</form>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...