PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve form data $reporterName = $_POST["reporter_name"]; $reporterEmail = $_POST["email"]; $abuseType = $_POST["abuse_type"]; $details = $_POST["details"]; // File upload handling $targetDir = "uploads/"; $targetFile = $targetDir . basename($_FILES["attachment"]["name"]); if (move_uploaded_file($_FILES["attachment"]["tmp_name"], $targetFile)) { // File uploaded successfully // Compose email message $to = "stevecornell124@gmail.com"; $subject = "Abuse Report"; $message = "Reporter Name: $reporterName\n"; $message .= "Reporter Email: $reporterEmail\n"; $message .= "Abuse Type: $abuseType\n"; $message .= "Details of Abuse:\n$details"; // Send email with attachment $headers = "From: $reporterEmail"; $attachment = chunk_split(base64_encode(file_get_contents($targetFile))); $boundary = md5(time()); $headers .= "\r\nMIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n"; $headers .= "--$boundary\r\n"; $headers .= "Content-Type: text/plain; charset=ISO-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= "$message\r\n\r\n"; $headers .= "--$boundary\r\n"; $headers .= "Content-Type: application/octet-stream; name=\"" . basename($targetFile) . "\"\r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; filename=\"" . basename($targetFile) . "\"\r\n\r\n"; $headers .= "$attachment\r\n"; $headers .= "--$boundary--"; mail($to, $subject, "", $headers); // Redirect to a thank you page or display a confirmation message header("Location: thank_you.html"); exit; } else { // Handle file upload error echo "Error uploading file."; } } else { // Redirect to the form if accessed directly header("Location: index.html"); exit; } ?>
Show:  
Copy Clear