title: PHPmailer - preg_match() expects parameter 2 to be string, array given
body: <p>The code below <em>used to work fine a while ago</em>, sending emails with images to Blogger's email; or sending emails to any provided email address. Unfortunately I have no idea when it stopped working and how to fix it. The error given is</p>
  <pre><code>Array ( [type] =&gt; 2 [message] =&gt; preg_match() expects parameter 2 to be string, array given [file] =&gt; /var/www/html/PHPMailer.php [line] =&gt; 4533 )
  </code></pre>
  <p>Below is the page, I appreciate if someone could fix it.</p>
  <pre><code>&lt;?php
  // error_reporting(0);
  // ini_set('display_errors', 0);
  var_dump($_POST[&quot;name&quot;]); 
  var_dump($_POST[&quot;age&quot;]);
  var_dump($_FILES);
      use PHPMailer\PHPMailer\PHPMailer;
      use PHPMailer\PHPMailer\Exception;
  
  $error = '';
  $name = '';
  $age = '';
  $email = '';
  $subject = '';
  $country = '';
  $message = '';
  $msg = '';
  $youtube = '';
  
  function clean_text($string)
  {
   $string = trim($string);
   $string = stripslashes($string);
   $string = htmlspecialchars($string);
   return $string;
  }
  
  if(isset($_POST[&quot;submit&quot;]))
  {
   if(empty($_POST[&quot;name&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Please Enter your Name&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $name = clean_text($_POST[&quot;name&quot;]);
    if(!preg_match(&quot;/^[a-zA-Z ]*$/&quot;,$name))
    {
     $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Only letters and white space allowed&lt;/label&gt;&lt;/p&gt;';
    }
   }
   //age
   if(empty($_POST[&quot;age&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Please Enter your Age&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $age = clean_text($_POST[&quot;age&quot;]);
    if(!preg_match(&quot;/^[0-9]*$/&quot;,$age))
    {
     $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Only numbers allowed&lt;/label&gt;&lt;/p&gt;';
    }
   }
   //age
   //i am
   if(empty($_POST['formGender'])) 
  {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Select your gender&lt;/label&gt;&lt;/p&gt;';
  }
   //i am
    //looking for
   if(empty($_POST['formGender2'])) 
  {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Select your Partner&lt;/label&gt;&lt;/p&gt;';
  }
    //looking for
      //for
   if(empty($_POST['formGender3'])) 
  {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Select your preferences&lt;/label&gt;&lt;/p&gt;';
  }
    //for
   if(empty($_POST[&quot;email&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Please Enter your Email&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $email = clean_text($_POST[&quot;email&quot;]);
    if(!filter_var($email, FILTER_VALIDATE_EMAIL))
    {
     $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Invalid email format&lt;/label&gt;&lt;/p&gt;';
    }
   }
   if(empty($_POST[&quot;subject&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;City/Town is required&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $subject = clean_text($_POST[&quot;subject&quot;]);
   }
   //country 
   if(empty($_POST[&quot;country&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Country is required&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $subject = clean_text($_POST[&quot;country&quot;]);
   }
   //country
   if(empty($_POST[&quot;youtube&quot;]))
   {
   // $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Please Enter your Name&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $youtube = clean_text($_POST[&quot;youtube&quot;]);
   }
   if(empty($_POST[&quot;message&quot;]))
   {
    $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Message is required&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $message = clean_text($_POST[&quot;message&quot;]);
   }
   if(empty($_POST[&quot;phone&quot;]))
   {
   // $error .= '&lt;p&gt;&lt;label class=&quot;text-danger&quot;&gt;Message is required&lt;/label&gt;&lt;/p&gt;';
   }
   else
   {
    $phone = clean_text($_POST[&quot;phone&quot;]);
   }
   
   
   if($error == '')
   {
  if (array_key_exists('userfile', $_FILES)) {
  if (isset($_SERVER[&quot;HTTP_CF_CONNECTING_IP&quot;])) {
    $_SERVER['REMOTE_ADDR'] = $_SERVER[&quot;HTTP_CF_CONNECTING_IP&quot;];
  }
  $ip = $_SERVER['REMOTE_ADDR'];
      require 'Exception.php';
      require 'PHPMailer.php';
      require 'SMTP.php';
      $mail = new PHPMailer;
    $mail-&gt;IsSMTP();        //Sets Mailer to send message using SMTP
    $mail-&gt;Host = 'smtp.gmail.com';  //Sets the SMTP hosts
    $mail-&gt;Port = '465';        //Sets the default SMTP server port
    $mail-&gt;SMTPAuth = true;       //Sets SMTP authentication. Utilizes the Username and Password variables
    $mail-&gt;Username = 'asdfdfgndfbgasdf';     //Sets SMTP username
    $mail-&gt;Password = 'asdfsgdbfsfg';     //Sets SMTP password
    $mail-&gt;SMTPSecure = 'ssl';       //Sets connection prefix. Options are &quot;&quot;, &quot;ssl&quot; or &quot;tls&quot;
    $mail-&gt;From = $_POST[&quot;email&quot;];     //Sets the From email address for the message
    $mail-&gt;FromName = $_POST[&quot;name&quot;];    //Sets the From name of the message
    $mail-&gt;AddAddress('asdfasdf.dfnghdfghfgh@blogger.com', 'Name');//Adds a &quot;To&quot; address
    $mail-&gt;AddCC($_POST[&quot;email&quot;], $_POST[&quot;name&quot;]); //Adds a &quot;Cc&quot; address
    $mail-&gt;WordWrap = 1000;       //Sets word wrapping on the body of the message to a given number of characters
    $mail-&gt;IsHTML(true);       //Sets message type to HTML    
    $mail-&gt;Subject = $_POST[&quot;name&quot;] . ', ' . $_POST['formGender'] . ' (' . $_POST[&quot;age&quot;] . ') looking to ' . $_POST[&quot;formGender3&quot;] . ' in ' . $_POST[&quot;subject&quot;] . ' ' . $_POST[&quot;country&quot;];    //Sets the Subject of the message
   if(empty($_POST[&quot;youtube&quot;]))
   {
    $mail-&gt;Body = '&lt;div id=&quot;intro&quot;&gt; Meet &lt;span style=&quot;text-transform: capitalize;&quot;&gt;' . $_POST[&quot;name&quot;] . '&lt;/span&gt;, a ' . $_POST[&quot;age&quot;] . ' yo ' . $_POST[&quot;formGender&quot;] . ' looking for ' . $_POST[&quot;formGender2&quot;] . ' to ' . $_POST[&quot;formGender3&quot;] . ' in ' . $_POST[&quot;subject&quot;] . ' ' . $_POST[&quot;country&quot;] . '. If you want to ' . $_POST[&quot;formGender3&quot;] . ' in ' . $_POST[&quot;subject&quot;] . ', ' . $_POST[&quot;country&quot;] . ', leave a message for ' . $_POST[&quot;name&quot;] . ' on this page or use the contact details below.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Email&lt;/strong&gt; ' . $_POST[&quot;email&quot;] . ' &lt;br/&gt;&lt;strong&gt;Phone&lt;/strong&gt; ' .  $_POST[&quot;phone&quot;] . '.&lt;/div&gt;&lt;div id=&quot;beforeblock&quot;&gt;... more about ' . $_POST[&quot;name&quot;] . ' below, in their own words: &lt;/div&gt;&lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;' . $_POST[&quot;message&quot;] . '&lt;/blockquote&gt;&lt;div id=&quot;regip&quot;&gt;Profile registered from IP &lt;strong&gt;&lt;a href=&quot;https://href.li/?https://whatismyipaddress.com/ip/' . $ip . '&quot; rel=&quot;nofollow noopener noreferrer&quot; target=&quot;_blank&quot;&gt;' . $ip . '&lt;/a&gt;&lt;/strong&gt;&lt;/div&gt;&lt;iframe width=&quot;600&quot; height=&quot;500&quot; id=&quot;gmap_canvas&quot; src=&quot;https://maps.google.com/maps?q=' . $_POST['subject'] . ',' . $_POST['country'] . '&amp;t=&amp;z=10&amp;ie=UTF8&amp;iwloc=&amp;output=embed&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; loading=&quot;lazy&quot; style=&quot;width:100%;max-width:100%;height:auto;min-height:315px;&quot;&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;span id=&quot;tags&quot;&gt;' . $_POST['formGender'] . ', ' . $_POST['subject'] . ', ' . $_POST['country'] . '&lt;/span&gt;';     //An HTML or plain text message body
   }
   if($_POST[&quot;youtube&quot;])
   {
    $mail-&gt;Body = '&lt;div id=&quot;intro&quot;&gt; Meet &lt;span style=&quot;text-transform: capitalize;&quot;&gt;' . $_POST[&quot;name&quot;] . '&lt;/span&gt;, a ' . $_POST[&quot;age&quot;] . ' yo ' . $_POST[&quot;formGender&quot;] . ' looking for ' . $_POST[&quot;formGender2&quot;] . ' to ' . $_POST[&quot;formGender3&quot;] . ' in ' . $_POST[&quot;subject&quot;] . ' ' . $_POST[&quot;country&quot;] . '. If you want to ' . $_POST[&quot;formGender3&quot;] . ' in ' . $_POST[&quot;subject&quot;] . ', ' . $_POST[&quot;country&quot;] . ', leave a message for ' . $_POST[&quot;name&quot;] . ' on this page or use the contact details below.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Email&lt;/strong&gt; ' . $_POST[&quot;email&quot;] . ' &lt;br/&gt;&lt;strong&gt;Phone&lt;/strong&gt; ' .  $_POST[&quot;phone&quot;] . '.&lt;/div&gt;&lt;div id=&quot;beforeblock&quot;&gt;... more about ' . $_POST[&quot;name&quot;] . ' below, in their own words: &lt;/div&gt;&lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;' . $_POST[&quot;message&quot;] . '&lt;/blockquote&gt;&lt;iframe loading=&quot;lazy&quot; style=&quot;width:100%;min-height:315px;height:auto;margin:0 5px;&quot; width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/' . $_POST[&quot;youtube&quot;] . '&quot; title=&quot;Video&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; id=&quot;youtubeframe&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;div id=&quot;regip&quot;&gt;Profile registered from IP &lt;strong&gt;&lt;a href=&quot;https://href.li/?https://whatismyipaddress.com/ip/' . $ip . '&quot; rel=&quot;nofollow noopener noreferrer&quot; target=&quot;_blank&quot;&gt;' . $ip . '&lt;/a&gt;&lt;/strong&gt;&lt;/div&gt;&lt;iframe width=&quot;600&quot; height=&quot;500&quot; id=&quot;gmap_canvas&quot; src=&quot;https://maps.google.com/maps?q=' . $_POST['subject'] . ',' . $_POST['country'] . '&amp;t=&amp;z=10&amp;ie=UTF8&amp;iwloc=&amp;output=embed&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; loading=&quot;lazy&quot; style=&quot;width:100%;max-width:100%;height:auto;min-height:200px;&quot;&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;span id=&quot;tags&quot;&gt;' . $_POST['formGender'] . ', ' . $_POST['subject'] . ', ' . $_POST['country'] . '&lt;/span&gt;';    //An HTML or plain text message body
  }
    $mail-&gt;set('X-Priority', '3'); //Priority 1 = High, 3 = Normal, 5 = low
  
  //photo 
  
      //Attach multiple files one by one
      for ($ct = 0, $ctMax = count($_FILES['userfile']['tmp_name']); $ct &lt; $ctMax; $ct++) {
          //Extract an extension from the provided filename
          $ext = PHPMailer::mb_pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);
          //Define a safe location to move the uploaded file to, preserving the extension
          $uploadfile = tempnam(sys_get_temp_dir(), hash('sha256', $_FILES['userfile']['name'][$ct])) . '.' . $ext;
          $filename = $_FILES['userfile']['name'][$ct];
          if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) {
              if (!$mail-&gt;addAttachment($uploadfile, $filename)) {
                  $msg .= 'Failed to upload the photos ' . $filename;
              }
          } else {
              $msg .= 'Failed to move photo to ' . $uploadfile;
          }
      }
  
  // $mail-&gt;AddAttachment($image_location);
  //photos
    
    if($mail-&gt;Send())        //Send an Email. Return true on success or false on error
    {
     $error = '&lt;label class=&quot;text-success&quot;&gt;Thank you for registering your profile. It will be visible soon after aproval.&lt;/label&gt;&lt;style&gt;.form-container {display:none!important;}&lt;/style&gt;';
    }
    else
    {
     $error = '&lt;label class=&quot;text-danger&quot;&gt;Your profile was not registered. Please try again!&lt;/label&gt;';
  //   $errorMessage = error_get_last()['message'];
  //    echo $errorMessage;
  //   var_dump($_FILES);
  print_r(error_get_last());
    }
    $name = '';
    $age = '';
    $email = '';
    $subject = '';
    $country = '';
    $message = '';
    $msg = '';
    $youtube = '';
    } //if img check ends
   } //if error ends
   
  }
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;style&gt;
  .form-container{width:96%;MAX-WIDTH:96%;margin:0 2%;}
  .form-group{margin-bottom:10px}
  .btn{background:#1c94ff;padding:4px 8px;border:none;box-shadow:2px 1px 1px #d3d3d3;color:#fff;outline:0;font-size:17px;cursor:pointer;width:100%}
  label{display:block;margin-bottom:2px}
  .form-group .form-control{width:100%;outline:0;padding:5px;border:none;background:#d1d1d1;border-bottom:2px solid #1c94ff;font-size:16px}
  .has-success .form-control{border-bottom:2px solid #168b3f}
  .has-danger .form-control{border-bottom:2px solid #dc1d34}
  .form-group .text-help{color:#dc1d34}
  .inline-label label{display:inline}
  .pristine-error{display:table}
    &lt;/style&gt;
  
  &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
  if (typeof jQuery == 'undefined'){
      document.write(unescape(&quot;%3Cscript src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js' type='text/javascript'%3E%3C/script%3E&quot;));
  }
  &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
       &lt;?php echo $error; ?&gt;
       &lt;div style=&quot;float:right;font-style: italic;&quot;&gt;&lt;span style=&quot;color:red;font-style: normal;&quot;&gt;!&lt;/span&gt; = mandatory&lt;/div&gt;
  
  &lt;div class=&quot;form-container&quot;&gt;
       &lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; id=&quot;registercafebar&quot;&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Name&lt;/label&gt;
         &lt;input type=&quot;text&quot; name=&quot;name&quot; required minlength=&quot;3&quot; maxlength=&quot;20&quot; placeholder=&quot;Enter Your Name&quot; class=&quot;form-control&quot; value=&quot;&lt;?php echo $name; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Age&lt;/label&gt;
         &lt;input required type=&quot;number&quot; minlength=&quot;2&quot; maxlength=&quot;2&quot; min=&quot;16&quot; max=&quot;99&quot; name=&quot;age&quot; placeholder=&quot;Enter your real age&quot; class=&quot;form-control&quot; value=&quot;&lt;?php echo $age; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; I am a&lt;/label&gt;
  &lt;select required name=&quot;formGender&quot; class=&quot;form-control&quot;&gt;
      &lt;option value=&quot;&quot;&gt;Select your gender at birth&lt;/option&gt;
      &lt;option value=&quot;woman&quot;&gt;Woman&lt;/option&gt;
      &lt;option value=&quot;man&quot;&gt;Man&lt;/option&gt;
  &lt;/select&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Looking for a&lt;/label&gt;
  &lt;select name=&quot;formGender2&quot; required class=&quot;form-control&quot;&gt;
    &lt;option value=&quot;&quot;&gt;Select who you are looking for&lt;/option&gt;
    &lt;option value=&quot;man&quot;&gt;Man&lt;/option&gt;
    &lt;option value=&quot;woman&quot;&gt;Woman&lt;/option&gt;
    &lt;option value=&quot;couples&quot;&gt;Couple&lt;/option&gt;
  &lt;/select&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; For&lt;/label&gt;
  &lt;select name=&quot;formGender3&quot; required class=&quot;form-control&quot;&gt;
    &lt;option value=&quot;&quot;&gt;Select what your intentions are&lt;/option&gt;
    &lt;option value=&quot;date&quot;&gt;Dating&lt;/option&gt;
    &lt;option value=&quot;chat&quot;&gt;Chat&lt;/option&gt;
    &lt;option value=&quot;marry&quot;&gt;Marriage&lt;/option&gt;
    &lt;option value=&quot;have sex&quot;&gt;Sex&lt;/option&gt;
  &lt;/select&gt;
       &lt;/div&gt; 
        
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; City&lt;/label&gt;
         &lt;input type=&quot;text&quot; name=&quot;subject&quot; required class=&quot;form-control&quot; minlength=&quot;2&quot; maxlength=&quot;25&quot; placeholder=&quot;Enter your City/Town&quot; value=&quot;&lt;?php echo $subject; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Country&lt;/label&gt;
         &lt;input type=&quot;text&quot; name=&quot;country&quot; required class=&quot;form-control&quot; minlength=&quot;2&quot; maxlength=&quot;20&quot; placeholder=&quot;Enter your Country&quot; value=&quot;&lt;?php echo $country; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; About me &lt;/label&gt;
         &lt;textarea name=&quot;message&quot; cols=&quot;30&quot; rows=&quot;5&quot; minlength=&quot;200&quot; maxlength=&quot;1000&quot; required class=&quot;form-control&quot; placeholder=&quot;Describe who you are and what you are looking for, write about the things you like or dislike or talk about your hobbies, but keep it spam free.&quot;&gt;&lt;?php echo $message; ?&gt;&lt;/textarea&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Email&lt;/label&gt;
         &lt;input type=&quot;email&quot; name=&quot;email&quot; class=&quot;form-control&quot; minlength=&quot;6&quot; maxlength=&quot;30&quot; required placeholder=&quot;Enter Your Email&quot; value=&quot;&lt;?php echo $email; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;Phone&lt;/label&gt;
         &lt;input type=&quot;number&quot; name=&quot;phone&quot; class=&quot;form-control&quot; minlength=&quot;4&quot; maxlength=&quot;25&quot; placeholder=&quot;Enter Your Phone&quot; value=&quot;&lt;?php echo $phone; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       
       &lt;div class=&quot;form-group&quot;&gt;
         &lt;label&gt;Youtube video ID &lt;br/&gt;&lt;span style=&quot;text-decoration: line-through;&quot;&gt;https://www.youtube.com/watch?v=&lt;/span&gt;&lt;strong style=&quot;padding:0 5px;border:1px solid gray;&quot;&gt;fhgnfyhfth&lt;/strong&gt;&lt;/label&gt;
         &lt;input type=&quot;text&quot; name=&quot;video&quot; class=&quot;form-control&quot; minlength=&quot;5&quot; maxlength=&quot;15&quot; placeholder=&quot;Enter Your Youtube video&quot; value=&quot;&lt;?php echo $youtube; ?&gt;&quot; /&gt;
       &lt;/div&gt;
       
       &lt;div class=&quot;form-group&quot;&gt;
       &lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;10000000&quot;&gt;
          &lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Photos:
          &lt;input name=&quot;userfile[]&quot; required type=&quot;file&quot; multiple=&quot;multiple&quot; accept=&quot;image/*&quot;&gt;
  &lt;/div&gt;
      &lt;div id=&quot;message&quot;&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Please verify:&lt;/div&gt;
              &lt;div id=&quot;success&quot;&gt;Perfect &amp;#10003;&lt;/div&gt;
              &lt;div id=&quot;fail&quot;&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Try again&lt;/div&gt;
  &lt;p id=&quot;question&quot;&gt;&lt;/p&gt; &lt;input id=&quot;ans&quot; type=&quot;text&quot;&gt;
  
  &lt;p&gt;&lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt; Are you human?&lt;br/&gt; No &lt;input type=&quot;checkbox&quot; name=&quot;no&quot;&gt; Yes &lt;input type=&quot;checkbox&quot; name=&quot;yes&quot; required&gt;&lt;/p&gt;
  &lt;script&gt;
  function setCookie(cname, cvalue, exdays) {
      var d = new Date();
      d.setTime(d.getTime() + (exdays*24*60*60*1000));
      var expires = &quot;expires=&quot;+d.toUTCString();
      document.cookie = cname + &quot;=&quot; + cvalue + &quot;; &quot; + expires;
  }
  &lt;/script&gt;
  &lt;div class=&quot;form-group inline-label&quot;&gt;
            &lt;span style=&quot;color:red&quot;&gt;!&lt;/span&gt;  &lt;input id=&quot;ch1&quot; type=&quot;checkbox&quot; name=&quot;future&quot; required data-pristine-required-message=&quot;You must accept the terms and conditions&quot;/&gt;
            &lt;label for=&quot;ch1&quot;&gt;I accept the terms  and conditions&lt;/label&gt;&lt;br/&gt;
        &lt;/div&gt;
        &lt;div class=&quot;form-group&quot;&gt;
         &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Register&quot; class=&quot;btn btn-info&quot; disabled=&quot;disabled&quot;  /&gt;&lt;!--disabled=&quot;disabled&quot;--&gt;
        &lt;/div&gt;
       &lt;/form&gt;
  &lt;/div&gt;
  &lt;div class=&quot;timer&quot; onload=&quot;timer(1800)&quot;&gt;
    &lt;div class=&quot;time&quot;&gt;
      &lt;strong&gt;Time until the page will refresh: &lt;span id=&quot;time&quot;&gt;Loading...&lt;/span&gt;&lt;/strong&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;br/&gt;
  &lt;script&gt;
       var total;
  function getRandom() {
    return Math.ceil(Math.random() * 20);
  }
  function createSum() {
    var randomNum1 = getRandom(),
      randomNum2 = getRandom();
    total = randomNum1 + randomNum2;
    jQuery(&quot;#question&quot;).text(randomNum1 + &quot; + &quot; + randomNum2 + &quot;=&quot;);
    jQuery(&quot;#ans&quot;).val('');
    checkInput();
  }
  
  function checkInput() {
    var input = jQuery(&quot;#ans&quot;).val(),
      slideSpeed = 200,
      hasInput = !!input,
      valid = hasInput &amp;&amp; input == total;
    jQuery('#message').toggle(!hasInput);
    jQuery('input[type=submit]').prop('disabled', !valid);
    jQuery('#success').toggle(valid);
    jQuery('#fail').toggle(hasInput &amp;&amp; !valid);
  }
  
  jQuery(document).ready(function() {
    //create initial sum
    createSum();
    // On &quot;reset button&quot; click, generate new random sum
    jQuery('input[type=reset]').click(createSum);
    // On user input, check value
    jQuery(&quot;#ans&quot;).keyup(checkInput);
    //cookie registered
  });
       &lt;/script&gt;
     
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>If it matters, I am using PHP 7.3, NginX. From my knowledge, same config as when the script used to work.</p>
  <p><strong>Also tried this:</strong></p>
  <p>Adding the following right after &lt;?php, following the comments</p>
  <pre><code>var_dump($_POST[&quot;name&quot;]); 
  var_dump($_POST[&quot;age&quot;]);
  var_dump($_FILES);
  </code></pre>
  <p>Returns this before submitting the form:</p>
  <pre><code>NULL NULL array(0) { }
  </code></pre>
  <p>And this after submitting the form:</p>
  <pre><code>string(14) &quot;Johny macaroni&quot; string(2) &quot;22&quot; array(1) { [&quot;userfile&quot;]=&gt; array(5) { [&quot;name&quot;]=&gt; array(1) { [0]=&gt; string(8) &quot;oslo.png&quot; } [&quot;type&quot;]=&gt; array(1) { [0]=&gt; string(9) &quot;image/png&quot; } [&quot;tmp_name&quot;]=&gt; array(1) { [0]=&gt; string(14) &quot;/tmp/phpen1nVm&quot; } [&quot;error&quot;]=&gt; array(1) { [0]=&gt; int(0) } [&quot;size&quot;]=&gt; array(1) { [0]=&gt; int(28358) } } }
  </code></pre>