if ($_POST['test'] === '9') { $file_name = "filename.ext"; $file_path = realpath(dirname(__FILE__)) . "/Files/" . $file_name; if (file_exists($file_path) && is_file($file_path)) { header('Content-Type: application/octet-stream'); header('Content-Description: File Transfer'); header('Cache-Control: must-revalidate'); header('Content-Length: ' . filesize($file_path)); header('Content-Disposition: attachment; filename=' . $file_name); header('Expires: 0'); header('Pragma: public'); readfile($file_path); } else { $error = "The file " . $file_name . " doesn't exist!"; } writeDataToFile($_POST['name'], $_POST['email'], $_POST['phone']); } } else { $error = "All fields are required"; } } ?> <!doctype html> <html lang="ro"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>Descarca</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1">
function sentMail($email, $passForEmail, $mailData) { require_once 'swiftmailer/lib/swift_required.php'; // Create message $message = "You have feedback from " . $mailData['name'] . " (email: " . $mailData['email'] . " skype: " . $mailData['skype'] . ") \n\n " . $mailData['message']; // Create the Transport $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($email)->setPassword($passForEmail); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); // Create a message $message = Swift_Message::newInstance('UI Crystal contact us')->setFrom(array($mailData['email'] => $mailData['name']))->setTo(array('*****@*****.**', '*****@*****.**' => 'Info'))->setBody($message); $mail = $mailer->send($message); return $mail; } function writeDataToFile($fileName, $text) { $current = file_get_contents($fileName); $current .= $text . "\n"; file_put_contents($fileName, $current); } $contactFormData = $_POST['contactUs']; if (!empty($contactFormData)) { writeDataToFile('emailList.txt', $contactFormData['email'] . ' ' . $contactFormData['skype']); if (sentMail('*****@*****.**', 'eg3s22dA', $contactFormData)) { $responce = ['status' => 'ok']; } else { $responce = ['status' => 'fail']; } echo json_encode($responce); } exit;