Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP将图像嵌入表单_Php_Html_Forms - Fatal编程技术网

PHP将图像嵌入表单

PHP将图像嵌入表单,php,html,forms,Php,Html,Forms,我已经尝试了很多不同的教程,试图让这个工作,但没有任何效果。这是我正在使用的代码,目前它工作得很好,除非我嵌入图像。一旦我嵌入图像,电子邮件就不会收到 <?php $field_website = $_POST['cf_website']; $field_name = $_POST['cf_name']; $field_age = $_POST['cf_age']; $field_email = $_POST['cf_email']; $field_cell = $_POST['cf_c

我已经尝试了很多不同的教程,试图让这个工作,但没有任何效果。这是我正在使用的代码,目前它工作得很好,除非我嵌入图像。一旦我嵌入图像,电子邮件就不会收到

<?php

$field_website = $_POST['cf_website'];
$field_name = $_POST['cf_name'];
$field_age = $_POST['cf_age'];
$field_email = $_POST['cf_email'];
$field_cell = $_POST['cf_cell'];
$field_tutor = $_POST['cf_tutor'];
$field_instrument = $_POST['cf_instrument'];
$field_lesson_type = $_POST['cf_lesson_type'];
$field_no_of_lessons = $_POST['cf_number'];
$field_amount_due = $_POST['cf_amount'];
$field_ref_num = $_POST['cf_ref_num'];

$field_booking_date = $_POST['cf_booking_date'];
$field_start_time = $_POST['cf_start_time'];
$field_end_time = $_POST['cf_end_time'];

$field_booking_date2 = $_POST['cf_booking_date2'];
$field_start_time2 = $_POST['cf_start_time2'];
$field_end_time2 = $_POST['cf_end_time2'];

$field_booking_date3 = $_POST['cf_booking_date3'];
$field_start_time3 = $_POST['cf_start_time3'];
$field_end_time3 = $_POST['cf_end_time3'];

$field_booking_date4 = $_POST['cf_booking_date4'];
$field_start_time4 = $_POST['cf_start_time4'];
$field_end_time4 = $_POST['cf_end_time4'];

if (empty($field_name) && empty($field_email) && empty($field_cell) && empty($field_tutor)) {
    echo 'Please fill in all required fields';
    return false;
}

else{
//process the rest of the form
}

if($field_website != ''){
    echo "Submission Sent - Thank you!";
    return false;
}

else{
//process the rest of the form
}

$mail_to = 'bookings@test.com';

$subject = 'Student Booking';
$headers = "From: " . strip_tags($field_email) . "\r\n";
$headers .= "Reply-To: ". strip_tags($field_email) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$body_message = '<html><body style="font-family:calibri,sans-serif; font-size:18px">';
$body_message .= '<h2 style="font-weight:600; font-size:27px; border-bottom:dashed 1px #CCC; padding-bottom:10px;">Student Booking</h2>';
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Full Name:</strong> '.$field_name."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Age:</strong> '.$field_age."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">E-mail Address:</strong> '.$field_email."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Cellphone Number:</strong> '.$field_cell."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Tutor Name:</strong> '.$field_tutor."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Instrument to Learn:</strong> '.$field_instrument."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Lesson Type:</strong> '.$field_lesson_type."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Number of Lessons:</strong> '.$field_no_of_lessons."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Amount Due:</strong> R'.$field_amount_due."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Reference Number:</strong> #'.$field_ref_num."</p>\n"."\n";

$body_message .= '<p><strong style="color:#000; font-weight:600; ">Booking Date:</strong> '.$field_booking_date."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">Start Time:</strong> '.$field_start_time."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">End Time:</strong> '.$field_end_time."</p>\n"."\n";

$body_message .= '<p><strong style="color:#000; font-weight:600; ">2nd Booking Date:</strong> '.$field_booking_date2."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">2nd Start Time:</strong> '.$field_start_time2."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">2nd End Time:</strong> '.$field_end_time2."</p>\n"."\n";

$body_message .= '<p><strong style="color:#000; font-weight:600; ">3rd Booking Date:</strong> '.$field_booking_date3."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">3rd Start Time:</strong> '.$field_start_time3."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">3rd End Time:</strong> '.$field_end_time3."</p>\n"."\n";

$body_message .= '<p><strong style="color:#000; font-weight:600; ">4th Booking Date:</strong> '.$field_booking_date4."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">4th Start Time:</strong> '.$field_start_time4."</p>\n"."\n";
$body_message .= '<p><strong style="color:#000; font-weight:600; ">4th End Time:</strong> '.$field_end_time4."</p>\n"."\n";
$body_message .= '</body></html>';

$autoTo = "$field_email";

$subject_auto = 'Booking Received!';
$headers_auto = "From: " . strip_tags('bookings@test.com') . "\r\n";
$headers_auto .= "Reply-To: ". strip_tags('bookings@test.com') . "\r\n";
$headers_auto .= "MIME-Version: 1.0\r\n";
$headers_auto .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$auto_body = '<html><body style="font-family:calibri,sans-serif; font-size:18px">';
$auto_body .= '<p>Dear '.$field_name."</p>\n"."\n";
$auto_body .= '<p>Thank you for booking at We See Musically! Confirmation of your booking details are shown below: '."</p>\n"."\n";
$auto_body .= '<p><strong>Tutor Name:</strong> '.$field_tutor."</p>\n"."\n";
$auto_body .= '<p><strong>Instrument Chosen:</strong> '.$field_instrument."</p>\n"."\n";
$auto_body .= '<p><strong>Lesson Type:</strong> '.$field_lesson_type."</p>\n"."\n";
$auto_body .= '<p><strong>Number of Lessons:</strong> '.$field_no_of_lessons."</p>\n"."\n";
$auto_body .= '<p>Please note that the amount due is R'.$field_amount_due.' and your reference number is #'.$field_ref_num.'. Please kindly make sure to use your reference number otherwise your booking will not be processed. Once payment has been received, your tutors full residential address as well as your booked dates and times will be emailed to you.  '."</p>\n"."\n";
$auto_body .= "<p>We trust you'll have a great tutoring experience at We See Musically!  "."</p>\n"."\n";
$auto_body .= '<img src="http://test.com/images/wsm-logo.png" ALT="We See Musically">';
$auto_body .= '</body></html>';


mail($autoTo, $subject_auto, $auto_body, $headers_auto);

mail($mail_to, $subject, $body_message, $headers);

?>

发送电子邮件相当复杂,因此我建议您使用经过测试的库,而不是直接使用PHP的
mail()
函数

一些邮件服务使用非常旧的软件。他们可能会拒绝包含超过70个字符的行的电子邮件(我见过这种情况),或者拒绝包含ASCII以外字符的电子邮件。这只是冰山一角,所以很难说你的具体信息有什么问题

如果您要编写自己的邮件实现,应该先阅读一些相关的RFC,如PHP手册中提到的:

以下RFC可能有用:»RFC 1896,»RFC 2045,»RFC 2046, »RFC 2047、»RFC 2048、»RFC 2049和»RFC 2822


或者你可以使用像
Zend\Mail
PEAR::Mail
SwiftMailer
PHPMailer
这样的库,依靠这些软件包的开发人员所做的测试。

你是如何发送电子邮件的?你正在使用任何库吗?只是通过php发送它。显示该库的代码。。此外,您还设置了两次内容类型。。没有必要那样做。。不需要第6-9行。我已经更改了上面的代码,以反映我正在使用的完整php代码,并删除了原来的第6-9行。:)尝试使用sendgrid或mailchimp的mandrill应用程序发送相同的电子邮件。赔率是您的SMTP服务器不太符合标准的Web标准,和任何电子邮件服务,你正在测试是过滤你的电子邮件内容。几个月前,我遇到了一个类似的问题,切换到sendgrid
神奇地解决了这个问题。