Page 1 of 1

Re: PHP Version 7.2

Posted: Fri May 17, 2019 8:04 pm
by Pablo
No, I meant the PHP code of the page : Menu -> Page -> Page HTML

Re: PHP Version 7.2

Posted: Fri May 17, 2019 8:09 pm
by Starb7
Ah, sorry. Left work now so will get this posted up ASAP. Cheers

Re: PHP Version 7.2

Posted: Fri May 17, 2019 8:12 pm
by Starb7
Just got this from the hosting folk.

PHP 7.2 no longer supports the $HTTP_POST_VARS, as this was removed in PHP 7, having been deprecated in PHP 5 by PHP's developers.

This has been replaced with $_POST - as such the code will need to change to reference $_POST instead.

As an example - if the variable $information was passed in the post for the form, and the document refers to itself on the post trigger, to acquire the variable you could use:

if($_SERVER["REQUEST_METHOD"] == "POST"){
$information = $_POST["information"];
}

As a comparison, HTTP_POST_VARS was not possible at a function level in PHP, only available at a file level, whereas _POST is available to all variables, hence HTTP_POST_VARS removal.

Does this help?

Cheers

Re: PHP Version 7.2

Posted: Sat May 18, 2019 6:32 am
by Pablo
No, this does not help because it is unrelated to the problem.
The WWB form script does not use $HTTP_POST_VARS !

Re: PHP Version 7.2

Posted: Sat May 18, 2019 8:57 am
by Starb7
What does it use? I can go back with the info as they may be able to help. Thanks

Re: PHP Version 7.2

Posted: Sat May 18, 2019 9:53 am
by Pablo
WWB uses $_POST, but again, this is unrelated to the problem.
The server error indicates a problem related to the email address.

Re: PHP Version 7.2

Posted: Sat May 18, 2019 10:01 am
by Starb7
That's odd because this is the code if manually created which works in 5.6. NOTE: I have commented out the variables and as you can see, at the bottom created 'test variables' and emailed those. This actually works fine so not an issue with the email address. if I then uncomment the lines (and remove the temp bits) it fails with the error and indicates the variables have no actually come through from the form. Also note, if I use the built-in form processor, at also fails under 7.2 and works in 5.6 with the same email address.

You say it's OK, the hosting people say there end is OK - I am passing the info between you to try and get it working so any idea's would be helpful and appreciated.

TIA.

<?php

ini_set("sendmail_from", " clerk@sutton-cum-duckmanton.org.uk ");

// $permission = $_POST['permission'];
// $name = $_POST['name'];
// $phone = $_POST['phone'];
// $email = $_POST['email'];
// $subject = $_POST['subject'];
// $message = $_POST['message'];

$thetimestamp = date("Y-m-d H:i:s");

// $EmailBody = "A Message from the S-c-D Web siteContact-Us \n\n";
// $EmailBody .= "On " .$thetimestamp ." this message was sent by " .$name ." as follows:" ."\n\n";
// $EmailBody .= "My Telephone number: " .$phone ."\n";
// $EmailBody .= "My Contact Email Address: " .$email ."\n\n";
// $EmailBody .= "My Message is:\n\n" .$message;
// $EmailBody .= "\n\n========== End of Message ==========\n\n";
// $EmailBody .= "[This email has been processed by the Supake Auto-Mailing System]";

// Get Status of Permission Box - and add msg if needed.

// Validate and send the message

$to = "info@supake.co.uk";
$subject = "a subject";
$emailBody = "hello world";

$headers = "From: clerk@sutton-cum-duckmanton.org.uk";

mail($to,$subject,$emailBody,$headers);

?>

Re: PHP Version 7.2

Posted: Sat May 18, 2019 12:27 pm
by Pablo
What is the PHP code of the page?

Re: PHP Version 7.2

Posted: Sun May 19, 2019 1:47 am
by bkjohns
Email address(es) in < > perhaps?

Re: PHP Version 7.2

Posted: Mon May 20, 2019 6:59 am
by Starb7
Hi Pablo,

Sorry, I thought you meant the PHP code for the form. The page in on a standard php page that has an iFrame with the form and results page. The code of the page is:

Code: Select all

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contact Us:: Sutton-cum-Duckmanton Parish Council</title>
<meta name="author" content="Supake Ltd   t: 01246 826557">
<meta name="generator" content="Supake Ltd   t: 01246 826557">
<link href="SuttonCD.css" rel="stylesheet">
<link href="contactus.css" rel="stylesheet">
</head>
<body>
<div id="container">
<div id="wb_Text2" style="position:absolute;left:23px;top:301px;width:305px;height:37px;z-index:4;">
<span style="color:#2D722F;font-family:Arial;font-size:32px;"><strong>Contact Us</strong></span></div>
<div id="wb_EmbeddedPage1" style="position:absolute;left:0px;top:0px;width:840px;height:299px;z-index:5;">
<div id="wb_Image1" style="position:absolute;left:26px;top:0px;width:385px;height:299px;z-index:0;">
<img src="images/Logo.jpg" id="Image1" alt=""></div>
<img src="images/img0003.png" id="Text1" alt="Sutton-cum-Duckmanton " style="position:absolute;left:313px;top:156px;width:527px;height:50px;z-index:1;">
<img src="images/img0001.png" id="MergedObject1" alt="" title="" style="border-width:0;position:absolute;left:314px;top:216px;width:484px;height:20px;z-index:2">
<div id="wb_CssMenu1" style="position:absolute;left:310px;top:254px;width:478px;height:29px;z-index:3;">
<ul role="menubar">
<li class="firstmain"><a role="menuitem" href="./index.html" target="_self" title="Home">Home</a>
</li>
<li><a role="menuitem" href="./Reports.html" target="_self" title="Reports">Reports</a>
</li>
<li><a role="menuitem" class="active" href="./contactus.php" target="_self" title="Contact Us">Contact&nbsp;Us</a>
</li>
</ul>
</div>
</div>
<div id="wb_Text5" style="position:absolute;left:23px;top:1373px;width:215px;height:14px;z-index:6;">
<span style="color:#A9A9A9;font-family:Verdana;font-size:12px;"><em><a href="./contactus.php">Go to top of page</a></em></span></div>
<iframe name="ContactUsForm" id="InlineFrame1" style="position:absolute;left:190px;top:477px;width:518px;height:466px;z-index:7;" src="./sendform.php" scrolling="no"></iframe>
<div id="wb_Contact_Us_text" style="position:absolute;left:23px;top:348px;width:801px;height:90px;z-index:8;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">You can contact us via the form below.&nbsp; Please complete the form, click the 'Consent' check box and press 'Send'.&nbsp; Alternatively, you can contact the Clerk on 01246 826955 during normal office hours.<br><br>You may also be able to contact any one of the current Councillors - to view the current list, please click <a href="http://sutton-cum-duckmanton.org.uk/docs/Councillors- website.pdf" target="_blank" title="Current Councillors in PDF Format">HERE</a> (to open or download) a list in PDF format. </span></div>
</div>
</body>
</html>
The Form (on a PHP PAGE) is this but please NOTE that I have turn off the built-in for testing and so the result page is handling the form at the moment but in both cases, the form is failing:

Code: Select all

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SendForm</title>
<meta name="author" content="Supake Ltd   t: 01246 826557">
<meta name="generator" content="Supake Ltd   t: 01246 826557">
<link href="SuttonCD.css" rel="stylesheet">
<link href="sendform.css" rel="stylesheet">
<script>
function ValidateContactUsForm()
{
   var regexp;
   var name = document.getElementById('name');
   if (!(name.disabled || name.style.display === 'none' || name.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-',]*$/;
      if (!regexp.test(name.value))
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value == "")
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value.length < 3)
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value.length > 100)
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
   }
   var phone = document.getElementById('phone');
   if (!(phone.disabled || phone.style.display === 'none' || phone.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-',]*$/;
      if (!regexp.test(phone.value))
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value == "")
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value.length < 3)
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value.length > 50)
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
   }
   var email = document.getElementById('email');
   if (!(email.disabled || email.style.display === 'none' || email.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (!regexp.test(email.value))
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value == "")
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value.length < 3)
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value.length > 50)
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
   }
   var subject = document.getElementById('subject');
   if (!(subject.disabled || subject.style.display === 'none' || subject.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-', ?]*$/;
      if (!regexp.test(subject.value))
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value == "")
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value.length < 3)
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value.length > 50)
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
   }
   var message = document.getElementById('message');
   if (!(message.disabled || message.style.display === 'none' || message.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-, . ? £]*$/;
      if (!regexp.test(message.value))
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value == "")
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value.length < 3)
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value.length > 250)
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
   }
   return true;
}
</script>
</head>
<body>
<div id="wb_contactusForm1" style="position:absolute;left:1px;top:0px;width:471px;height:433px;z-index:15;">
<form name="ContactUsForm" method="post" action="sentform.php" id="contactusForm1" onsubmit="return ValidateContactUsForm()">
<input type="text" id="name" style="position:absolute;left:126px;top:18px;width:335px;height:20px;z-index:0;" name="name" value="" maxlength="100" tabindex="10" spellcheck="false" title="What is your name?" placeholder="Your Preferred Contact Name">
<label for="contactusForm1" id="contactusLabel1" style="position:absolute;left:19px;top:12px;width:68px;height:35px;line-height:35px;z-index:1;" tabindex="0">Name *</label>
<input type="text" id="phone" style="position:absolute;left:126px;top:55px;width:335px;height:20px;z-index:2;" name="phone" value="" maxlength="100" tabindex="20" spellcheck="false" title="What is your Phone Number?" placeholder="A number can we call you on if needed">
<label for="contactusLabel1" id="contactusLabel2" style="position:absolute;left:19px;top:49px;width:68px;height:35px;line-height:35px;z-index:3;" tabindex="0">Phone *</label>
<input type="text" id="email" style="position:absolute;left:126px;top:92px;width:335px;height:20px;z-index:4;" name="email" value="" maxlength="100" tabindex="30" spellcheck="false" title="What is your Email Address?" placeholder="Your Preferred Email Address">
<label for="contactusLabel2" id="contactusLabel3" style="position:absolute;left:19px;top:86px;width:68px;height:35px;line-height:35px;z-index:5;">Email *</label>
<input type="text" id="subject" style="position:absolute;left:126px;top:129px;width:335px;height:20px;z-index:6;" name="subject" value="" maxlength="100" tabindex="40" spellcheck="false" title="What is the Subject of your Query?" placeholder="What do you want to contact us about?">
<label for="contactusLabel3" id="contactusLabel4" style="position:absolute;left:19px;top:122px;width:84px;height:35px;line-height:35px;z-index:7;">Subject *</label>
<label for="contactusLabel4" id="contactusLabel5" style="position:absolute;left:19px;top:234px;width:94px;height:35px;line-height:35px;z-index:8;">Message *</label>
<textarea name="message" id="message" style="position:absolute;left:126px;top:173px;width:335px;height:146px;z-index:9;" rows="7" cols="40" tabindex="50" spellcheck="false" title="Your Message" placeholder="Your Message up to a maximum of 250 characters. Some charactes are not allowed, if you cannot send your message please remove any special characters, eg ! ? @ # and so on, then try again."></textarea>
<label for="" id="contactusLabel6" style="position:absolute;left:121px;top:384px;width:330px;height:20px;line-height:20px;z-index:10;" title="(* All fields are required)">(* All fields are required)</label>
<input type="submit" id="contactusButton1" name="Send" value="Send" style="position:absolute;left:363px;top:386px;width:96px;height:25px;z-index:11;" title="Send your Query!">
<div id="wb_permission" style="position:absolute;left:126px;top:339px;width:33px;height:27px;z-index:12;">
<input type="checkbox" id="permission" name="permission" value="Permisson has been given to Contact this person." style="position:absolute;left:0;top:0;" title="Can we contact you if needed?"><label for="permission"></label></div>
<div id="wb_Text1" style="position:absolute;left:158px;top:345px;width:308px;height:36px;z-index:13;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Consent - can we contact you if needed?</span></div>
<div id="wb_Text2" style="position:absolute;left:19px;top:403px;width:55px;height:10px;z-index:14;">
<span style="color:#696969;font-family:Verdana;font-size:8px;">v1.15</span></div>
</form>
</div>
</body>
</html>
and the Results (manual code) code this this:

Code: Select all

<?php

// All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS.

ini_set("sendmail_from", " clerk@sutton-cum-duckmanton.org.uk ");

// $permission = $_POST['permission'];
// $name = $_POST['name'];
// $phone = $_POST['phone'];
// $email = $_POST['email'];
// $subject = $_POST['subject'];
// $message = $_POST['message'];

$thetimestamp = date("Y-m-d H:i:s");

// $EmailBody = "A Message from the S-c-D Web siteContact-Us \n\n";
// $EmailBody .= "On " .$thetimestamp ." this message was sent by " .$name ." as follows:" ."\n\n";
// $EmailBody .= "My Telephone number: " .$phone ."\n";
// $EmailBody .= "My Contact Email Address: " .$email ."\n\n";
// $EmailBody .= "My Message is:\n\n" .$message;
// $EmailBody .= "\n\n========== End of Message ==========\n\n";
// $EmailBody .= "[This email has been processed by the Supake Auto-Mailing System]";

// Get Status of Permission Box -  and add msg if needed.

// Validate and send the message

$to = "info@supake.co.uk";
$subject = "a subject";
$emailBody = "hello world";

$headers = "From: clerk@sutton-cum-duckmanton.org.uk";

mail($to,$subject,$emailBody,$headers);

?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>sentform</title>
<meta name="author" content="Supake Ltd   t: 01246 826557">
<meta name="generator" content="Supake Ltd   t: 01246 826557">
<link href="SuttonCD.css" rel="stylesheet">
<link href="sentform.css" rel="stylesheet">
</head>
<body>
<div id="wb_Image1" style="position:absolute;left:4px;top:2px;width:365px;height:283px;z-index:0;">
<img src="images/Logo.jpg" id="Image1" alt=""></div>
<div id="wb_Text1" style="position:absolute;left:21px;top:320px;width:445px;height:36px;text-align:center;z-index:1;">
<span style="color:#4F4F4F;font-family:Verdana;font-size:15px;">Your Message has been processed and sent.&nbsp; We will be in touch as soon as we can.&nbsp; Thank you for your interest.</span></div>
<img src="images/img0002.png" id="Text2" alt="Thank You " style="position:absolute;left:226px;top:194px;width:221px;height:50px;z-index:2;">
</body>
</html>
Happy to try anything and do any testing...

Thanks.

Re: PHP Version 7.2

Posted: Mon May 20, 2019 7:13 am
by Pablo
I'm sorry, but this is not the PHP code generated by the built-in form script.

1. Open the page in the software
2. Menu -> Page -> Page HTML

Re: PHP Version 7.2

Posted: Mon May 20, 2019 8:27 am
by Starb7
Ok, I have changed it to use the built-in form now and here the page code:

Code: Select all

<?php
function ValidateEmail($email)
{
   $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
   return preg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'contactusform1')
{
   $mailto = 'clerk@sutton-cum-duckmanton.org.uk';
   $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
   $subject = 'Web Page Contact Us Form';
   $message = 'A Message from the ScD Contact Us Form as follows:

';
   $success_url = './sentform.php';
   $error_url = './sentform.php';
   $error = '';
   $eol = "\n";
   $boundary = md5(uniqid(time()));

   $header  = 'From: '.$mailfrom.$eol;
   $header .= 'Reply-To: '.$mailfrom.$eol;
   $header .= 'MIME-Version: 1.0'.$eol;
   $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
   $header .= 'X-Mailer: PHP v'.phpversion().$eol;
   if (!ValidateEmail($mailfrom))
   {
      $error .= "The specified email address is invalid!\n<br>";
   }

   if (!empty($error))
   {
      $errorcode = file_get_contents($error_url);
      $replace = "##error##";
      $errorcode = str_replace($replace, $error, $errorcode);
      echo $errorcode;
      exit;
   }

   $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
   $message .= $eol;
   $logdata = '';
   foreach ($_POST as $key => $value)
   {
      if (!in_array(strtolower($key), $internalfields))
      {
         if (!is_array($value))
         {
            $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
         }
         else
         {
            $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
         }
      }
   }
   $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
   $body .= '--'.$boundary.$eol;
   $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
   $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
   $body .= $eol.stripslashes($message).$eol;
   if (!empty($_FILES))
   {
       foreach ($_FILES as $key => $value)
       {
          if ($_FILES[$key]['error'] == 0)
          {
             $body .= '--'.$boundary.$eol;
             $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
             $body .= 'Content-Transfer-Encoding: base64'.$eol;
             $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
             $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
          }
      }
   }
   $body .= '--'.$boundary.'--'.$eol;
   if ($mailto != '')
   {
      mail($mailto, $subject, $body, $header);
   }
   header('Location: '.$success_url);
   exit;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SendForm</title>
<meta name="author" content="Supake Ltd   t: 01246 826557">
<meta name="generator" content="Supake Ltd   t: 01246 826557 - using a mix of technologies to get you results!">
<link href="SuttonCD.css" rel="stylesheet">
<link href="sendform.css" rel="stylesheet">
<script>
function ValidateContactUsForm()
{
   var regexp;
   var name = document.getElementById('name');
   if (!(name.disabled || name.style.display === 'none' || name.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-',]*$/;
      if (!regexp.test(name.value))
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value == "")
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value.length < 3)
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
      if (name.value.length > 100)
      {
         alert("What is your name?");
         name.focus();
         return false;
      }
   }
   var phone = document.getElementById('phone');
   if (!(phone.disabled || phone.style.display === 'none' || phone.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-',]*$/;
      if (!regexp.test(phone.value))
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value == "")
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value.length < 3)
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
      if (phone.value.length > 50)
      {
         alert("What is your Phone Number");
         phone.focus();
         return false;
      }
   }
   var email = document.getElementById('email');
   if (!(email.disabled || email.style.display === 'none' || email.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (!regexp.test(email.value))
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value == "")
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value.length < 3)
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
      if (email.value.length > 50)
      {
         alert("What is your Email Address?");
         email.focus();
         return false;
      }
   }
   var subject = document.getElementById('subject');
   if (!(subject.disabled || subject.style.display === 'none' || subject.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-', ?]*$/;
      if (!regexp.test(subject.value))
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value == "")
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value.length < 3)
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
      if (subject.value.length > 50)
      {
         alert("What is the Subject of your Query?");
         subject.focus();
         return false;
      }
   }
   var message = document.getElementById('message');
   if (!(message.disabled || message.style.display === 'none' || message.style.visibility === 'hidden'))
   {
      regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-, . ? £]*$/;
      if (!regexp.test(message.value))
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value == "")
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value.length < 3)
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
      if (message.value.length > 250)
      {
         alert("What is your message?");
         message.focus();
         return false;
      }
   }
   return true;
}
</script>
</head>
<body>
<div id="wb_contactusForm1" style="position:absolute;left:1px;top:0px;width:471px;height:433px;z-index:15;">
<form name="ContactUsForm" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="contactusForm1" onsubmit="return ValidateContactUsForm()">
<input type="hidden" name="formid" value="contactusform1">
<input type="text" id="name" style="position:absolute;left:126px;top:18px;width:335px;height:20px;z-index:0;" name="name" value="" maxlength="100" tabindex="10" spellcheck="false" title="What is your name?" placeholder="Your Preferred Contact Name">
<label for="contactusForm1" id="contactusLabel1" style="position:absolute;left:19px;top:12px;width:68px;height:35px;line-height:35px;z-index:1;" tabindex="0">Name *</label>
<input type="text" id="phone" style="position:absolute;left:126px;top:55px;width:335px;height:20px;z-index:2;" name="phone" value="" maxlength="100" tabindex="20" spellcheck="false" title="What is your Phone Number?" placeholder="A number can we call you on if needed">
<label for="contactusLabel1" id="contactusLabel2" style="position:absolute;left:19px;top:49px;width:68px;height:35px;line-height:35px;z-index:3;" tabindex="0">Phone *</label>
<input type="text" id="email" style="position:absolute;left:126px;top:92px;width:335px;height:20px;z-index:4;" name="email" value="" maxlength="100" tabindex="30" spellcheck="false" title="What is your Email Address?" placeholder="Your Preferred Email Address">
<label for="contactusLabel2" id="contactusLabel3" style="position:absolute;left:19px;top:86px;width:68px;height:35px;line-height:35px;z-index:5;">Email *</label>
<input type="text" id="subject" style="position:absolute;left:126px;top:129px;width:335px;height:20px;z-index:6;" name="subject" value="" maxlength="100" tabindex="40" spellcheck="false" title="What is the Subject of your Query?" placeholder="What do you want to contact us about?">
<label for="contactusLabel3" id="contactusLabel4" style="position:absolute;left:19px;top:122px;width:84px;height:35px;line-height:35px;z-index:7;">Subject *</label>
<label for="contactusLabel4" id="contactusLabel5" style="position:absolute;left:19px;top:234px;width:94px;height:35px;line-height:35px;z-index:8;">Message *</label>
<textarea name="message" id="message" style="position:absolute;left:126px;top:173px;width:335px;height:146px;z-index:9;" rows="7" cols="40" tabindex="50" spellcheck="false" title="Your Message" placeholder="Your Message up to a maximum of 250 characters. Some charactes are not allowed, if you cannot send your message please remove any special characters, eg ! ? @ # and so on, then try again."></textarea>
<label for="" id="contactusLabel6" style="position:absolute;left:121px;top:384px;width:330px;height:20px;line-height:20px;z-index:10;" title="(* All fields are required)">(* All fields are required)</label>
<input type="submit" id="contactusButton1" name="Send" value="Send" style="position:absolute;left:363px;top:386px;width:96px;height:25px;z-index:11;" title="Send your Query!">
<div id="wb_permission" style="position:absolute;left:126px;top:339px;width:33px;height:27px;z-index:12;">
<input type="checkbox" id="permission" name="permission" value="Permisson has been given to Contact this person." style="position:absolute;left:0;top:0;" title="Can we contact you if needed?"><label for="permission"></label></div>
<div id="wb_Text1" style="position:absolute;left:158px;top:345px;width:308px;height:36px;z-index:13;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Consent - can we contact you if needed?</span></div>
<div id="wb_Text2" style="position:absolute;left:19px;top:403px;width:55px;height:10px;z-index:14;">
<span style="color:#696969;font-family:Verdana;font-size:8px;">v1.15</span></div>
</form>
</div>
</body>
</html>
Cheers

p.s. Built-in or manual, neither work :(

Re: PHP Version 7.2

Posted: Mon May 20, 2019 8:58 am
by Pablo
I do not see any errors in the code.
And as you can see, there are no refferences to $HTTP_POST_VARS anywhere!

The only reason I can think of why this code does not work is an issue on the server side.

Re: PHP Version 7.2

Posted: Mon May 20, 2019 9:05 am
by Starb7
Thanks for the update. Yes, I know (from previous posts) it's using the right POST format. I have asked them to check again... thanks for your help. Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 1:57 pm
by Starb7
Hi Pablo

Been on this all morning (with the hosting folks) and have got to this point. If you go to
http://sutton-cum-duckmanton.org.uk/bogstandardmail/ and use the top form which is a Built-In form processor, it fails but if you use the lower form, which send it to showvars2.php and processes the code manually it works.

Note that you can use any From and To email address and so probably not a security issue.

The only thing we noticed while testing is that the code is now case sensitive, ie if you use $to = $_POST['to']; (using the form data) and then try and use such as mail($To,$Subject,$EmailBody,$Headers); ie, a cap T, then it fails.

Could it be that the built-in form is changing the case and has PHP7.2 got more case sensitive?

Any further pointers help would be appreciated but as we can now use manually processed form date, we have a work-around for now.

Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 2:23 pm
by Pablo
PHP has always been case sensitive and so it the built-in form script.

Note that I cannot see what the PHP code of the test page is, so I cannot say anything meaningful about why the forms work or not.
What is the PHP code of showvars2.php?

Re: PHP Version 7.2

Posted: Mon May 20, 2019 2:40 pm
by Starb7
Hi Pablo

Here's the HTML code of Showvars2.php:

Code: Select all

<?php

// ini_set("sendmail_from", "info@supake.co.uk");
ini_set("sendmail_from", "xxxxx@yyyyy.zzzzz");

$thevariables = $_POST['thevariables'];
$from = $_POST['from'];
$to = $_POST['to'];

$Subject = "Variable testing";
$EmailBody = "Variable tests - the body - " ."\n\n" ."External Domain Used" ."\n\n" .$thevariables ."\n\n";
$EmailBody .= "FROM FIELD Specified was: " .$from ."\n\n";
$EmailBody .= "TO FIELD Specified was: " .$to;

// $Headers = "From: info@supake.co.uk";
$Headers = "From: " .$from;

mail($to,$Subject,$EmailBody,$Headers);

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
<link href="PHPMailIssues.css" rel="stylesheet">
<link href="showvars2.css" rel="stylesheet">
</head>
<body>
<div id="wb_Text1" style="position:absolute;left:27px;top:28px;width:900px;height:54px;z-index:0;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Nothing to see here - the email has been sent using PHP and not the built-in form.<br><br>NOTE: '$To' and '$FROM' are variably coded to an email address taken from the form.</span></div>
</body>
</html>
and the code of the forms page:

Code: Select all

<?php
function ValidateEmail($email)
{
   $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
   return preg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'form1')
{
   $mailto = 'info@supake.co.uk';
   $mailfrom = 'info@supake.co.uk';
   $subject = 'Test Bog Standard';
   $message = 'Values submitted from web site form:';
   $success_url = '#';
   $error_url = '#';
   $error = '';
   $eol = "\n";
   $boundary = md5(uniqid(time()));

   $header  = 'From: '.$mailfrom.$eol;
   $header .= 'Reply-To: '.$mailfrom.$eol;
   $header .= 'MIME-Version: 1.0'.$eol;
   $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
   $header .= 'X-Mailer: PHP v'.phpversion().$eol;
   if (!ValidateEmail($mailfrom))
   {
      $error .= "The specified email address is invalid!\n<br>";
   }

   if (!empty($error))
   {
      $errorcode = file_get_contents($error_url);
      $replace = "##error##";
      $errorcode = str_replace($replace, $error, $errorcode);
      echo $errorcode;
      exit;
   }

   $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
   $message .= $eol;
   $logdata = '';
   foreach ($_POST as $key => $value)
   {
      if (!in_array(strtolower($key), $internalfields))
      {
         if (!is_array($value))
         {
            $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
         }
         else
         {
            $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
         }
      }
   }
   $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
   $body .= '--'.$boundary.$eol;
   $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
   $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
   $body .= $eol.stripslashes($message).$eol;
   if (!empty($_FILES))
   {
       foreach ($_FILES as $key => $value)
       {
          if ($_FILES[$key]['error'] == 0)
          {
             $body .= '--'.$boundary.$eol;
             $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
             $body .= 'Content-Transfer-Encoding: base64'.$eol;
             $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
             $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
          }
      }
   }
   $body .= '--'.$boundary.'--'.$eol;
   if ($mailto != '')
   {
      mail($mailto, $subject, $body, $header);
   }
   header('Location: '.$success_url);
   exit;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>bogstandardemail</title>
<link href="PHPMailIssues.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
<script>
function ValidatebogstandardmailForm()
{
   var regexp;
   var Editbox1 = document.getElementById('Editbox1');
   if (!(Editbox1.disabled || Editbox1.style.display === 'none' || Editbox1.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (Editbox1.value.length != 0 && !regexp.test(Editbox1.value))
      {
         alert("Please enter a valid email address.");
         Editbox1.focus();
         return false;
      }
   }
   var Editbox2 = document.getElementById('Editbox2');
   if (!(Editbox2.disabled || Editbox2.style.display === 'none' || Editbox2.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (Editbox2.value.length != 0 && !regexp.test(Editbox2.value))
      {
         alert("Please enter a valid email address.");
         Editbox2.focus();
         return false;
      }
   }
   return true;
}
</script>
<script>
function ValidatebogstandardmailForm()
{
   var regexp;
   var Editbox7 = document.getElementById('Editbox7');
   if (!(Editbox7.disabled || Editbox7.style.display === 'none' || Editbox7.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (Editbox7.value.length != 0 && !regexp.test(Editbox7.value))
      {
         alert("Please enter a valid email address.");
         Editbox7.focus();
         return false;
      }
   }
   var Editbox8 = document.getElementById('Editbox8');
   if (!(Editbox8.disabled || Editbox8.style.display === 'none' || Editbox8.style.visibility === 'hidden'))
   {
      regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
      if (Editbox8.value.length != 0 && !regexp.test(Editbox8.value))
      {
         alert("Please enter a valid email address.");
         Editbox8.focus();
         return false;
      }
   }
   return true;
}
</script>
</head>
<body>
<div id="wb_Form1" style="position:absolute;left:51px;top:22px;width:447px;height:193px;z-index:15;">
<form name="bogstandardmailForm" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1" onsubmit="return ValidatebogstandardmailForm()">
<input type="hidden" name="formid" value="form1">
<input type="text" id="Editbox1" style="position:absolute;left:189px;top:17px;width:216px;height:18px;z-index:0;" name="from" value="" spellcheck="false">
<div id="wb_Text1" style="position:absolute;left:71px;top:22px;width:56px;height:18px;z-index:1;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">From</span></div>
<div id="wb_Text2" style="position:absolute;left:71px;top:61px;width:56px;height:18px;z-index:2;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">To</span></div>
<div id="wb_Text3" style="position:absolute;left:71px;top:95px;width:90px;height:18px;z-index:3;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Message</span></div>
<input type="text" id="Editbox2" style="position:absolute;left:189px;top:56px;width:216px;height:18px;z-index:4;" name="to" value="" spellcheck="false">
<input type="text" id="Editbox3" style="position:absolute;left:189px;top:95px;width:216px;height:18px;z-index:5;" name="message" value="Hello World - Auto Form" spellcheck="false">
<input type="submit" id="Button1" name="Send" value="Submit" style="position:absolute;left:312px;top:139px;width:96px;height:25px;z-index:6;">
</form>
</div>
<div id="wb_Text4" style="position:absolute;left:641px;top:164px;width:124px;height:18px;z-index:16;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">V1.17</span></div>
<div id="wb_Text9" style="position:absolute;left:540px;top:65px;width:249px;height:54px;z-index:17;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Note the <strong>From </strong>and <strong>To </strong>not used here as the Built-in code has that defined</span></div>
<div id="wb_Text11" style="position:absolute;left:548px;top:365px;width:249px;height:72px;z-index:18;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Note the<strong> Built-In form </strong>is <strong>not </strong>used here as the php code is used to process the form data and sends it to showvars2.php</span></div>
<div id="wb_Form3" style="position:absolute;left:51px;top:244px;width:447px;height:312px;z-index:19;">
<form name="bogstandardmailForm" method="post" action="showvars2.php" id="Form3" onsubmit="return ValidatebogstandardmailForm()">
<div id="wb_Text12" style="position:absolute;left:37px;top:40px;width:335px;height:18px;z-index:7;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Variables to send (some text):</span></div>
<input type="submit" id="Button3" name="Send" value="Submit" style="position:absolute;left:319px;top:236px;width:96px;height:25px;z-index:8;">
<input type="text" id="Editbox7" style="position:absolute;left:182px;top:87px;width:216px;height:18px;z-index:9;" name="from" value="" spellcheck="false">
<div id="wb_Text13" style="position:absolute;left:51px;top:141px;width:97px;height:18px;z-index:10;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">To</span></div>
<div id="wb_Text14" style="position:absolute;left:44px;top:87px;width:56px;height:18px;z-index:11;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">From</span></div>
<input type="text" id="Editbox8" style="position:absolute;left:182px;top:136px;width:216px;height:18px;z-index:12;" name="to" value="" spellcheck="false">
<input type="text" id="Editbox9" style="position:absolute;left:182px;top:188px;width:216px;height:18px;z-index:13;" name="thevariables" value="Hello World - PHP Coded" spellcheck="false">
<div id="wb_Text15" style="position:absolute;left:51px;top:193px;width:90px;height:18px;z-index:14;">
<span style="color:#000000;font-family:Verdana;font-size:15px;">Message</span></div>
</form>
</div>
</body>
</html>
Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 2:46 pm
by Starb7
p.s. any of the
// ini_set("sendmail_from", "info@supake.co.uk");
work. Also, are you able to send to and from a selection of email addresses using the form (to eliminate security issues)? Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 2:56 pm
by Pablo
Do you mean that it also works when you remove this?

Code: Select all

ini_set("sendmail_from", "clerk@sutton-cum-duckmanton.org.uk");
Note that you can define the 'from' address in the form's properties.

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:02 pm
by Starb7
I hadn't tried commenting that out so just gave it a go and yes, if you comment it out, it still works as expected. :) Cheers

Update: I have noticed that I can only send from (to anywhere) Fasthosts based email adders to there is some check going on...

p.p.s. having a lots of problems with the forum page, keeps timing out and very slow to load.

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:13 pm
by Pablo
Update: I have noticed that I can only send from (to anywhere) Fasthosts based email adders to there is some check going on...
Do you get the same error if you use another email address?

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:22 pm
by Starb7
Yes, I get
PHPWarning: mail(): SMTP server response: 554 5.7.1 <info@supake.co.uk>: Recipient address rejected: Access denied in \\HP3-WINC2-SMB2.HOSTINGP3.LOCAL\DOMAINSZ\952\1944952\user\htdocs\bogstandardmail\showvars2.php on line 18
Line 18 being: mail($to,$Subject,$EmailBody,$Headers);

Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:27 pm
by Pablo
So, this confirm that it's a server issue?

As mentioned you can set the 'from' address in the form's properties.

Image

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:38 pm
by Starb7
No, not really. I knew that you could do that (and did try that) in the Built-in forms but it doesn't work. I have just edited and added it back in to verify and it still fails. Cheers

Re: PHP Version 7.2

Posted: Mon May 20, 2019 3:54 pm
by Starb7
Well here's an oddity, if you go into the settings and choose 'Mail Engine' and select 'mail' the built-in form works as expected, why would that be? Cheers

EDIT: its gets better - it appears I can actually 'send from' any email address, even fictitious email addresses, eg foo@bar.com will send email. Give it a go, the bottom form... does it work for you?

Re: PHP Version 7.2

Posted: Mon May 20, 2019 5:06 pm
by Pablo
No, not really.
Yes, it does!
The script does not care which email address you use, so somewhere on the server sode there is a filter that checks which email address issue as 'from'.

[quotwhy would that be?[/quote]
Because it uses php mailer instead of standard PHP mail. This works different and may bypass some server specific configuration.

Re: PHP Version 7.2

Posted: Mon May 20, 2019 5:32 pm
by Starb7
Sorry, when you put
So, this confirm that it's a server issue?
, with a ? mark, I thought you were asking me. In any case, as I can either use 'hand coded' or 'PHP Mailer' for built-in forms, it's a win-win for me. Many thanks for your help and patience and as always, a top service. Thanks.