title: PHPMailer & Form to Database
body: <p>hey so i've been trying to send a mail to person who filled the form on my website,
  but im new to programming and i get the error of 500 when i run the code below. Or are there any other ways of sending email to form filler automaticly</p>
  
  <pre><code>if (isset($_POST['gp_save_idelegateadd_onsite']))   {
  
  
  *use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\Exception;
  require 'phpmailer/Exception.php';
  require 'phpmailer/PHPMailer.php';
  require 'phpmailer/SMTP.php';
  $lastname = $_GET['gp_applicant_lastname'];
  $email = $_GET['gp_applicant_mail'];
  /* creates object */
  $mail = new PHPMailer(true);
  $mailid = $email;
  $subject = "GOMailer - Regarding your ESMUN 2020 application.";
  $text_message = "Hello";
  $message = "Dear $lastname , your application is recieved to be reviewed.";
  try {
      $mail-&gt;IsSMTP();
      $mail-&gt;isHTML(true);
      $mail-&gt;SMTPDebug = 0;
      $mail-&gt;SMTPAuth = true;
      $mail-&gt;Host = "mail.gelecekodakliakademi.com";
      $mail-&gt;Port = '587';
      $mail-&gt;AddAddress($mailid);
      $mail-&gt;Username ="system@gelecekodakliakademi.com";
      $mail-&gt;Password ="-----]";
      $mail-&gt;SetFrom('system@gelecekodakliakademi.com','NoReply_GOMailer');
      $mail-&gt;AddReplyTo("system@gelecekodakliakademi.com","NoReply_GOMailer");
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $message;
      $mail-&gt;AltBody = $message;
      if($mail-&gt;Send()) { echo "Thank you for register u got a notification through the mail you provide"; } }
      catch(phpmailerException $ex)
      { $msg = " ".$ex-&gt;errorMessage()." "; }*
  
      // Form to Database
      $addconfig=$db-&gt;prepare("INSERT INTO applications SET
          gp_applicant_name = :gp_applicant_name,
          gp_applicant_lastname = :gp_applicant_lastname,
          gp_applicant_birthdate = :gp_applicant_birthdate,
          gp_applicant_mail = :gp_applicant_mail,
          gp_applicant_gender = :gp_applicant_gender,
          gp_applicant_city = :gp_applicant_city,
          gp_applicant_gsm = :gp_applicant_gsm,
          gp_applicant_school = :gp_applicant_school,
          gp_applicant_faculty = :gp_applicant_faculty,
          gp_applicant_munrel = :gp_applicant_munrel,
          gp_applicant_munrellist = :gp_applicant_munrellist,
          gp_applicant_pref1 = :gp_applicant_pref1,
          gp_applicant_pref2 = :gp_applicant_pref2,
          gp_applicant_pref3 = :gp_applicant_pref3,
          gp_applicant_letter = :gp_applicant_letter,
          gp_applicant_condition = :gp_applicant_condition,
          gp_applicant_what = :gp_applicant_what,
          gp_applicant_status = :gp_applicant_status ");
  
      $insert=$addconfig-&gt;execute(array(
          'gp_applicant_name' =&gt; $_POST['gp_applicant_name'],
          'gp_applicant_lastname' =&gt; $_POST['gp_applicant_lastname'],
          'gp_applicant_birthdate' =&gt; $_POST['gp_applicant_birthdate'],
          'gp_applicant_mail' =&gt; $_POST['gp_applicant_mail'],
          'gp_applicant_gender' =&gt; $_POST['gp_applicant_gender'],
          'gp_applicant_city' =&gt; $_POST['gp_applicant_city'],
          'gp_applicant_gsm' =&gt; $_POST['gp_applicant_gsm'],
          'gp_applicant_school' =&gt; $_POST['gp_applicant_school'],
          'gp_applicant_faculty' =&gt; $_POST['gp_applicant_faculty'],
          'gp_applicant_munrel' =&gt; $_POST['gp_applicant_munrel'],
          'gp_applicant_munrellist' =&gt; $_POST['gp_applicant_munrellist'],
          'gp_applicant_pref1' =&gt; $_POST['gp_applicant_pref1'],
          'gp_applicant_pref2' =&gt; $_POST['gp_applicant_pref2'],
          'gp_applicant_pref3' =&gt; $_POST['gp_applicant_pref3'],
          'gp_applicant_letter' =&gt; $_POST['gp_applicant_letter'],
          'gp_applicant_condition' =&gt; $_POST['gp_applicant_condition'],
          'gp_applicant_what' =&gt; $_POST['gp_applicant_what'],
          'gp_applicant_status' =&gt; $_POST['gp_applicant_status'] ));
  
          // Feedback
      if ($insert) {
          header("Location:../../../apply.php?view=delegate&amp;apply=ok");
      } else {
          header("Location:../../../apply.php?view=delegate&amp;apply=err");
      }
  
  }
  </code></pre>
  
  <p>the part</p>
  
  <pre><code>*use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\Exception;
  require 'phpmailer/Exception.php';
  require 'phpmailer/PHPMailer.php';
  require 'phpmailer/SMTP.php';
  $lastname = $_GET['gp_applicant_lastname'];
  $email = $_GET['gp_applicant_mail'];
  /* creates object */
  $mail = new PHPMailer(true);
  $mailid = $email;
  $subject = "GOMailer - Regarding your ESMUN 2020 application.";
  $text_message = "Hello";
  $message = "Dear $lastname , your application is recieved to be reviewed.";
  try {
      $mail-&gt;IsSMTP();
      $mail-&gt;isHTML(true);
      $mail-&gt;SMTPDebug = 0;
      $mail-&gt;SMTPAuth = true;
      $mail-&gt;Host = "mail.gelecekodakliakademi.com";
      $mail-&gt;Port = '587';
      $mail-&gt;AddAddress($mailid);
      $mail-&gt;Username ="system@gelecekodakliakademi.com";
      $mail-&gt;Password ="-----]";
      $mail-&gt;SetFrom('system@gelecekodakliakademi.com','NoReply_GOMailer');
      $mail-&gt;AddReplyTo("system@gelecekodakliakademi.com","NoReply_GOMailer");
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $message;
      $mail-&gt;AltBody = $message;
      if($mail-&gt;Send()) { echo "Thank you for register u got a notification through the mail you provide"; } }
      catch(phpmailerException $ex)
      { $msg = " ".$ex-&gt;errorMessage()." "; }*
  </code></pre>
  
  <p>I belive what caused the error cuz when I remove it, form goes to database without issue, thank you.</p>