При нажатии на странички кнопки "отправить" запускается скрипт, но первый оператор после <?php
уже не выполняется , например <?php echo "OK";
, ничего не выводит!
index.html:
<html>
<head>
<style>
form {
margin-left: 35%;
}
input {
margin: 1%;
}
body {
width: 80%;
}
.textfield {
width: 72%;
}
.content {
height: 300px;
margin-left: 1%;
resize: vertical;
}
</style>
</head>
<body>
<form method="POST" action="sender.php" enctype="multipart/form-data">
<input name="from" type="text" placeholder="Адрес отправителя" required class="textfield"><br>
<input name="to" type="text" placeholder="Адрес получателя" required class="textfield"><br>
<input name="subject" type="text" placeholder="Тема сообщения" class="textfield"><br>
<p><textarea class="content" name="message" placeholder="Текст сообщениея" cols="70"></textarea></p>
<input name="attachments[]" type="file"><br>
<input name="attachments[]" type="file"><br>
<input name="attachments[]" type="file"><br>
<input value="Отправить" type="submit">
</form>
</body>
</html>
sender.php
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
echo "OK";
if ($_POST && isset($_FILES['attachments'])) {
$recipient_email = $_POST['to'];
$from_email = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$attachments = $_FILES['attachments'];
$file_count = count($attachments['name']); //count total files attached
$boundary = md5("test");
if ($file_count > 0) { //if attachment eiists
//header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:" . $from_email . "\r\n";
$headers .= "Reply-To: " . $from_email . "" . "\r\n";
$headers .= "Content-Type: multipart/miied; boundary = $boundary\r\n\r\n";
//message teit
$body = "--$boundary\r\n";
$body .= "Content-Type: teit/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($message));
//attachments
for ($i = 0; $i < $file_count; $i++) {
if (!empty($attachments['name'][$i])) {
if ($attachments['error'][$i] > 0) //eiit script and output error if we encounter any
{
$mymsg = array(1 => "The uploaded file eiceeds the upload_mai_filesize directive in php.ini", 2 => "The uploaded file eiceeds the MAi_FILE_SIZE directive that was specified in the HTML form", 3 => "The uploaded file was only partially uploaded", 4 => "No file was uploaded", 6 => "Missing a temporary folder");
die($mymsg[$attachments['error'][$i]]);
}
//get file info
$file_name = $attachments['name'][$i];
$file_size = $attachments['size'][$i];
$file_type = $attachments['type'][$i];
//read file
$handle = fopen($attachments['tmp_name'][$i], "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content)); //split into smaller chunks (RFC 2045)
$body .= "--$boundary\r\n";
$body .= "Content-Type: $file_type; name="$file_name"\r\n";
$body .= "Content-Disposition: attachment; filename="$file_name"\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n";
$body .= "i-Attachment-Id: " . rand(1000, 99999) . "\r\n\r\n";
$body .= $encoded_content;
}
}
} else { //send plain email otherwise
$headers = "From:" . $from_email . "\r\n" . "Reply-To: " . $from_email . "\n" . "i-Mailer: PHP/" . phpversion();
$body = $message;
}
$sentMail = @mail($recipient_email, $subject, $body, $headers);
if ($sentMail) //output success or failure messages
{
die('Thank you for your email');
} else {
die('Could not send mail! Please check your PHP mail configuration.');
}
}
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
При запуске composer --profile update, сам composer показывает, что потребляет не много памяти ([1381MB/207
Есть переменная $a со значением 5 или 3Или же есть переменная $b с каким-то значением