Problem with "Send Form" 1.1.3

I had “Send Form” working until a few weeks ago. I.E. it would email:
Name
Surname
Email
Phone
Mobile
Address
Town
Postcode
Message

Then AFAIK “nothing changed” and it will now only send the email address, all other fields have been dropped??

Send Form is placed as a Page Item.

The form is here: NFC | Contact

Any ideas please!!!

Here is a TextEdit text of the .PHP Page

<?php global $errorStrings; global $errors; // CONFIG // Redirect pages $successPage = "nfcsuccess.html"; // Relative path for page to redirect to on success $errorPage = "nfcfailure.html"; // Relative path for page to redirect to on error, error numbers will be in a GET variable // E-Mail $recipient = "REDACTED"; // Address to deliver form to $subject = ""; // Subject of the E-Mail $from = ""; // From address if server requires it or if E-Mail address is optional $replyTo = ""; // The address to use for Reply-To header, will be set later based on email entered into form $name = ""; // The name of the sender, if required $useRecipientList = "0"; // Should the recipient be matched against options? $recipientList = array( ); // Server $allowsOtherDomains = TRUE; // Variables $input_vars = array( 'name' => array( 'title' => 'name', 'required' => '0', 'type' => 'firstName' ), 'surname' => array( 'title' => 'surname', 'required' => '0', 'type' => 'surname' ), 'email' => array( 'title' => 'email', 'required' => '0', 'type' => 'from', 'filter' => 'email' ), 'address1' => array( 'title' => 'address1', 'required' => '0' ), 'address2' => array( 'title' => 'address2', 'required' => '0' ), 'town' => array( 'title' => 'town', 'required' => '0' ), 'postcode' => array( 'title' => 'postcode', 'required' => '0' ), 'homePhone' => array( 'title' => 'homePhone', 'required' => '0' ), 'mobilePhone' => array( 'title' => 'mobilePhone', 'required' => '0' ), 'Unsubscribe' => array( 'title' => 'Unsubscribe', 'required' => '0' ), 'county' => array( 'title' => 'county', 'required' => '0' ) ); $reCaptchaRequired = false; // Error strings $errorStrings = array( 0 => 'Undefined error', 1 => 'No form submitted', 2 => 'Invalid E-Mail address', 3 => 'E-Mail could not be delivered', 4 => 'sendForm91976', // No real error message for this 5 => 'reCAPTCHA doesn\'t think you\'re human', ); // FUNCTIONS // void appendError(int $errorNum [, string $errorString]) // Append error for processing at the end function appendError($errorNum, $errorString = NULL) { global $errorStrings; global $errors; global $customErrorNum; if (!$errors) $errors = array(); if (!$customErrorNum) $customErrorNum = 0; if ($errorNum > 0 && array_key_exists($errorNum, $errorStrings)) $message = $errorStrings[$errorNum]; elseif ($errorString) $message = $errorString; else $message = $errorStrings[0]; if ($errorNum == 0) { $errors["c$customErrorNum"] = $message; $customErrorNum++; } else { $errors[$errorNum] = $message; } } // PROCESSING // Input // Determine if a form has been submitted and whether it was via POST or GET $input_type = INPUT_POST; if ($_SERVER['REQUEST_METHOD'] === 'POST') $input_type = INPUT_POST; elseif ($_SERVER['REQUEST_METHOD'] === 'GET') $input_type = INPUT_GET; else appendError(1); $recipientId = 0; // Before we go anywhere, was the form submitted by a human? if ($reCaptchaRequired) { $data['secret'] = ''; if ($input_type == INPUT_POST) { if (empty($_POST['g-recaptcha-response'])) appendError(5); else $data['response'] = $_POST['g-recaptcha-response']; } else { if (empty($_GET['g-recaptcha-response'])) appendError(5); else $data['response'] = $_GET['g-recaptcha-response']; } $url = 'https://www.google.com/recaptcha/api/siteverify'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $response = curl_exec($ch); $responseData = json_decode($response); if (!$responseData || $responseData->success == false) appendError(5); } else if (($input_type == INPUT_POST && !empty($_POST['sendForm91976']) || ($input_type == INPUT_GET && !empty($_GET['sendForm91976'])))) { // Probably not appendError(4); } if (!$errors) { $firstName = false; $surname = false; $parameters = ""; // A form has been submitted, iterate over the expected fields to // produce a message body $emailBody = 'This message has been sent from http://nettlebedfolkclub.co.uk/contact/ '; foreach($input_vars as $key => $var) { $field = NULL; if (filter_has_var($input_type, $key) && ($input_type == INPUT_POST ? !empty($_POST[$key]) : !empty($_GET[$key]))) { // If the field exists and isn't empty, sanitize the contents for security if (array_key_exists('filter', $var)) { switch ($var['filter']) { case 'email': $sanitized = filter_input($input_type, $key, FILTER_SANITIZE_EMAIL); if (!empty($sanitized)) { $field = $sanitized; if ($var['type'] == 'recipient') { $recipient = $field; $field = ''; } elseif ($var['type'] == 'from') $replyTo = $field; } else appendError(2); break; case 'integer': $sanitized = filter_input($input_type, $key, FILTER_SANITIZE_NUMBER_INT); if (!empty($sanitized)) { if ($var['type'] == 'recipient') $recipientId = $sanitized; else $field = $sanitized; } break; default: $field = filter_input($input_type, $key, FILTER_SANITIZE_ADD_SLASHES); } } else { $group = filter_input(INPUT_POST, $key, FILTER_SANITIZE_ADD_SLASHES, FILTER_REQUIRE_ARRAY); if(is_Array($group)) { for($i = 0; $i < count($group); $i++) { $field .= "$group[$i]"; if($group[$i+1]) $field .= ", "; } if(count($group) > 1) $field = "[$field]"; } else $field = filter_input($input_type, "$key", FILTER_SANITIZE_ADD_SLASHES); } if ($field && array_key_exists('type', $var)) { if ($var['type'] == 'firstName') { $firstName = $field; } elseif ($var['type'] == 'surname') { $surname = $field; } elseif ($var['type'] == 'subject') { $subject = $field; continue; } } } elseif (array_key_exists('required', $var) && $var['required']) { // The field doesn't exist or is empty but is required appendError(0, "$key is a required field"); } if ($field) { // Add the field to the message body $emailBody .= $var['title'] . ": $field\n"; } } } // Sending if (!$errors) { // If we haven't had any errors up to this point, try to send the E-Mail if ($firstName || $surname) { if ($firstName && $surname) $name = $firstName . " " . $surname; elseif ($firstName) $name = $firstName; else $name = $surname; } if ($useRecipientList && isset($recipientList)) if (count($recipientList) > $recipientId && $recipientId >= 0) $recipient = $recipientList[$recipientId]; $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n"; if (!empty($replyTo)) $headers .= 'Reply-To: ' . $replyTo . "\r\n"; $fromHeader = ""; if (!empty($from)) { if ($name) $fromHeader = "From: \"$name\" <$from>\r\n"; else $fromHeader = "From: $from\r\n"; } if (!$allowsOtherDomains && !empty($from)) $parameters = "-f$from"; $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader, $parameters); if (!$mailSuccess) { // Attempt to send from an address of the same domain as the server if ($name) $fromHeader = "From: \"$name\" \r\n"; else $fromHeader = "From: no-reply@" . $_SERVER['HTTP_HOST'] . "\r\n"; $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader, $parameters); if(!$mailSuccess) appendError(3); } } // Finishing up $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); if ((substr($errorPage, 0, 7) != 'http://') && (substr($errorPage, 0, 8) != 'https://')) { if (strpos($errorPage, "/") === 0) $errorPage = "http://$host$errorPage"; else $errorPage = "http://$host$uri/$errorPage"; } if ((substr($successPage, 0, 7) != 'http://') && (substr($successPage, 0, 8) != 'https://')) { if (strpos($successPage, "/") === 0) $successPage = "http://$host$successPage"; else $successPage = "http://$host$uri/$successPage"; } // If we have errors but the spam trap error is present, we pretend that we succeeded if ($errors && !array_key_exists(4, $errors)) { // We encountered errors so the E-Mail must not have been sent $errorsUrlString = urlencode(implode(",", $errors)); header("Location: $errorPage?$errorsUrlString"); } else { // E-Mail has been successfully accepted for delivery. This doesn't mean it will reach the // destination but that is out of our control now so all we can do is hope for the best header("Location: $successPage"); } ?>

These are the settings:

Hi Peter,

Are the other fields marked as required?

I tried filling in the form using my Softpress email address, and it didn’t report any errors. I also tried sending it without filling in any fields, and that didn’t report any errors either.

If this is for joining an email mailing list, I would be wary about giving out my postal address, mobile phone number, and home phone number, so I wonder if people are deliberately omitting that information.

Jeremy

There is an HTML required attribute that can be set on text fields in HTML5 pages, but this hasn’t been set on any of the fields on your page. The SendForm Action checks this attribute.

Hi Jeremy,

The form used to work until a few weeks ago. maybe my provider [Clook] has updated their version of PHP??

Where do I find " HTML required attribute that can be set on text fields in HTML5 page" please??

Hi Jeremy,

In your two attempts at filling in the form the first attempt only your email came through … on the second nothing came through.

There is a Required checkbox in the Output pane of the Inspector palette for Input/Field controls. There is some documentation about this in the Freeway Reference Guide on pages 199-200.

I think that probably makes sense: I left all the fields blank on my second attempt (to see what would happen).

Thanks Jeremy,

The pages were set to " HTML 4.01 Traditional" now “HTML5” and I have set all fields to “Required”

This makes no difference ;~{{

I have also created a new “Form Page” from scratch “http://nettlebedfolkclub.co.,uk/form2/” , also no difference.

Next:
I’m going to get my head round learning Xway. I’ll also try and setup this form/website in Xway too,

It does make a difference for me. If I try to send a form without filling in (say) the Home phone number, I get a popup saying “Fill out this field”.

I just filled it in a second time. Some of the information is bogus (I don’t even have a home phone), but it should work as a test. Did you get more than just my email address this time?

Xway doesn’t have any built-in form handling. It’s something we hope to look at in future, but forms have become increasingly problematic, and there are online form builders that can be used in the meantime.

Hi Jeremy,

Yes I have two new messages j@s . . . and test@example

Both are the same, just the email addresses!!

Oh and if it makes any difference the version of PHP is 5.6??

I have been in touch with {Clook} my domain provider.

Ben has been looking at the logs and came back with this:

<<
Hi, Peter.

Looking at the warnings (after changing the format of the FW_SendForm_index1.php file to make it more readable), I could see that the warning seems to relate to use of FILTER_SANITIZE_ADD_SLASHES in calls to filter_input(). That specific constant was only added in PHP 7.3, and putting the site on PHP version 7.3 seems to have got the form sending the full content again.

Ben

And lo the form is coming in again, complete!!

What just happened ???

All the fields have just started to come in with “test” as the answers and email as “test@example.com

I’m assuming that was you Jeremy???

How did that work!!??

I think you’re saying it’s now working. I didn’t send the test@example.com submissions - perhaps that was your domain provider?

See the message above from Ben @ Clook:

Hi, Peter.

Looking at the warnings (after changing the format of the FW_SendForm_index1.php file to make it more readable), I could see that the warning seems to relate to use of FILTER_SANITIZE_ADD_SLASHES in calls to filter_input(). That specific constant was only added in PHP 7.3, and putting the site on PHP version 7.3 seems to have got the form sending the full content again.

Ben

The minimum PHP version for the updated Send Form Action is in fact 7.3. It should also work with PHP 8, according to that page.

Glad it’s working now!

This (PHP version) is how this got fixed. You were using a modern send form Action with an antique version of PHP. The filter/sanitize stuff wasn’t even in that version of PHP. When your host changed you up to version 7.3, that suddenly made the script work. The fact that it was able to limp along to the point where it sent you at least the e-mail address before that change is surprising, but not impossible to imagine. But now that your host has the more modern PHP enabled, you should be able to use the modern features from Send Form in your sites.

Walter

Yipee do da … I think is said across the pond!!

This has been quite useful!! In a way . . .

Because I’ve updated the pages to HTML5 and turned-on the “required” button forcing people to complete, completely.

Thanks for your forbearance Jeremy, and comments Walter.