Hi everyone, first of all thanks for letting me join this Forum i look forward to being part of the group.
I have compiled a detailed application form for a website which uses normal text boxes, drop down option boxes, Calendar for dates, check boxes and attachment. I got the form to email beautifully using just normal PHP but i got stuck when dealing with the attachment section. I then learnt its best to use PHP Mailer so i have re done the PHP for this but getting the dreaded HTTP 500 error. Please could someone check out my code to see where i am going wrong please. Thank you very much in advance.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'href="/PHPMailer/src/Exception.php"';
require 'href="/PHPMailer/src/PHPMailer.php"';
$message = '';
function clean_text($string)
{
$string = trim($string);
$string = stripslashes($string);
$string = htmlspecialchars($string);
return $string;
}
if(isset($POST["submit"]))
{
$path = 'href="/upload/"' . $FILES["attachment"]["name"];
move_uploaded_file($FILES["attachment"]["tmp_name"], $path);
$message = '
<h3 align="center">Application Details</h3>
<table border="1" width="100%" cellpadding="5" cellspacing="5">
<tr>
<td width="30%">First Name</td>
<td width="70%">'.$POST["first_name"].'</td>
</tr>
<tr>
<td width="30%">Last Name</td>
<td width="70%">'.$POST["last_name"].'</td>
</tr>
<tr>
<td width="30%">Email Address</td>
<td width="70%">'.$POST["email"].'</td>
</tr>
<tr>
<td width="30%">Phone Number</td>
<td width="70%">'.$POST["phone_number"].'</td>
</tr>
<tr>
<td width="30%">Position</td>
<td width="70%">'.$POST["position"].'</td>
</tr>
<tr>
<td width="30%">WhatsApp Number</td>
<td width="70%">'.$POST["whatsapp_no"].'</td>
</tr>
<tr>
<td width="30%">Yacht Name</td>
<td width="70%">'.$POST["yacht_name"].'</td>
<tr>
<td width="30%">Yacht Type</td>
<td width="70%">'.$POST["yacht_type"].'</td>
</tr>
<tr>
<td width="30%">Yacht Size</td>
<td width="70%">'.$POST["yacht_size"].'</td>
</tr>
<tr>
<td width="30%">Cruising Type</td>
<td width="70%">'.$POST["cruising_type"].'</td>
</tr>
<tr>
<td width="30%">Yacht Location</td>
<td width="70%">'.$POST["yacht_location"].'</td>
</tr>
<tr>
<td width="30%">Yacht Itinenary</td>
<td width="70%">'.$POST["yacht_itinenary"].'</td>
</tr>
<tr>
<td width="30%">Work Posistion</td>
<td width="70%">'.$POST["work_position"].'</td>
</tr>
<tr>
<td width="30%">Work Type</td>
<td width="70%">'.$POST["work_type"].'</td>
</tr>
<tr>
<td width="30%">Start Date</td>
<td width="70%">'.$POST["start_date"].'</td>
</tr>
<tr>
<td width="30%">Finish Date</td>
<td width="70%">'.$POST["finishing_date"].'</td>
<tr>
<td width="30%">Visa Required</td>
<td width="70%">'.$POST["visa_req"].'</td>
</tr>
<tr>
<td width="30%">Qualifications Required</td>
<td width="70%">'.$POST["qual_req"].'</td>
</tr>
<tr>
<td width="30%">Job Description</td>
<td width="70%">'.$POST["job_desc"].'</td>
</tr>
<tr>
<td width="30%">Shared Cabin</td>
<td width="70%">'.$POST["shared_cabin"].'</td>
</tr>
<tr>
<td width="30%">Understood Terms</td>
<td width="70%">'.$POST["terms"].'</td>
</tr>
<tr>
<td width="30%">Confidental</td>
<td width="70%">'.$POST["confidential"].'</td>
</tr>
</table>
';
if (isset($POST['shared_cabin'])){
$POST['shared_cabin']; // Displays value of checked checkbox.
}
if (isset($POST['terms'])){
$POST['terms']; // Displays value of checked checkbox.
}
if (isset($POST['confidential'])){
$_POST['confidential']; // Displays value of checked checkbox.
}
require 'class/class.phpmailer.php';
$mail = new PHPMailer(TRUE);
$mail->From = $POST["email_from"]; //Sets the From email address for the message
$mail->FromName = $POST["first_name"]["last_name"]; //Sets the From name of the message
$mail->AddAddress('timmy2872@gmail.com'); //Adds a "To" address
$mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters
$mail->IsHTML(true); //Sets message type to HTML
$mail->AddAttachment($path); //Adds an attachment from a path on the filesystem
$mail->Subject = 'Employer Application Form details'; //Sets the Subject of the message
$mail->Body = $message; //An HTML or plain text message body
if($mail->Send()) //Send an Email. Return true on success or false on error
{
$message = '<div class="alert alert-success">Application Successfully Submitted</div>';
unlink($path);
}
else
{
$message = '<div class="alert alert-danger">There is an Error</div>';
}
}
?>