[Pro] Send Form woes

Another thing… I’m trying to use the Send Form Action, which I have used successfully before, but it’s not working. Not only does it not send, but it doesn’t go to either the error or success page. it goes to a blank .php page with the address of the form.

http://www.policypartners.net/test/FW_SendForm_index_contactTable1.php

Is this a server issue?

Thanks, David

(Would try PHP feedback form but this is an inline page element.)


freewaytalk mailing list
email@hidden
Update your subscriptions at:

It’s normal for a .php page to appear blank, because it contains programming statements, and unless those programming statements also output HTML, you won’t see any other content in a browser.

You may be seeing the “white screen of death” – a full-on stop-the-server error is happening, and because the (sensible) default in production servers is to never show the details of such an error to the visitor, you are just seeing the blank screen. You can diagnose this further by trying the following:

  1. Use an SFTP application like Transmit to open the file you linked to in an editor (or use Transmit’s built-in editor). You should see on the first line the <?php delimiter indicating that this is a script, followed by additional code.
  2. At the end of that first line, type a return, and add this line: ini_set('display_errors', 1); followed by a return. Then add another line: error_reporting(E_ALL); and another return.

This turns on visible errors, and turns up the error reporting to “KILL”.

This may make it clearer what is going on, but once you get some sort of result, you should turn this back off because it exposes details about your server that would be of interest to someone trying to hack it. Just delete those two lines, or add // before each line to comment it out.

Walter

On Oct 23, 2016, at 12:08 AM, David email@hidden wrote:

Another thing… I’m trying to use the Send Form Action, which I have used successfully before, but it’s not working. Not only does it not send, but it doesn’t go to either the error or success page. it goes to a blank .php page with the address of the form.

http://www.policypartners.net/test/FW_SendForm_index_contactTable1.php

Is this a server issue?

Thanks, David

(Would try PHP feedback form but this is an inline page element.)


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Hi, Walter-

If I just link directly to the .php page, I get this:

Notice: Use of undefined constant INPUT_POST - assumed ‘INPUT_POST’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 90

Notice: Use of undefined constant INPUT_GET - assumed ‘INPUT_GET’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 94

Notice: Use of undefined constant INPUT_POST - assumed ‘INPUT_POST’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 106

Notice: Use of undefined constant INPUT_GET - assumed ‘INPUT_GET’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 107

Fatal error: Call to undefined function filter_has_var() in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 125

Is this what you’re looking for?

Later, David

The .php page is-

<?php global $errorStrings; global $errors; // CONFIG // Redirect pages $successPage = ""; // Relative path for page to redirect to on success $errorPage = ""; // Relative path for page to redirect to on error, error numbers will be in a GET variable // E-Mail $recipient = "email@hidden"; // 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 $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( 'nameField' => array( 'title' => 'nameField', 'required' => '1', 'type' => 'firstName' ), 'emailField' => array( 'title' => 'emailField', 'required' => '1', 'type' => 'from', 'filter' => 'email' ), 'subjectField' => array( 'title' => 'subjectField', 'required' => '1' ) ); // Error strings $errorStrings = array( 0 => 'Undefined error', 1 => 'No form submitted', 2 => 'Invalid E-Mail address', 3 => 'E-Mail could not be delivered', 4 => 'sendForm41541', // No real error message for this ); // 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); // Are we in safe mode? $safeMode = ini_get('safe_mode'); // safe_mode can be 'On' or true $safeMode = ($safeMode == 'On' || $safeMode == true); $recipientId = 0; // Before we go anywhere, was the form submitted by a human? if (($input_type == INPUT_POST && !empty($_POST['sendForm41541']) || ($input_type == INPUT_GET && !empty($_GET['sendForm41541'])))) { // 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 = ''; 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 (filter_input($input_type, $key, FILTER_VALIDATE_EMAIL)) { $field = $sanitized; if ($var['type'] == 'recipient') { $recipient = $field; $field = ''; } elseif ($var['type'] == 'from' && $allowsOtherDomains) $from = $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_MAGIC_QUOTES); } } else { $group = filter_input(INPUT_POST, $key, FILTER_SANITIZE_MAGIC_QUOTES, 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_MAGIC_QUOTES); } 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'] . ": $fieldn"; } } } // 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' . "rn" . 'Content-type: text/plain; charset=UTF-8' . "rn"; if ($name) $fromHeader = "From: "$name" <$from>rn"; else $fromHeader = "From: $fromrn"; if (!$allowsOtherDomains) $parameters = "-f$from"; if ($safeMode) $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader); else $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" rn"; else $fromHeader = "From: no-reply@" . $_SERVER['HTTP_HOST'] . "rn"; if ($safeMode) $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader); else $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"); } ?>

freewaytalk mailing list
email@hidden
Update your subscriptions at:

It sounds to me as though your server is using a different version of PHP than this script was written for. What do you see as the version when you do the following?

  1. Make a new plain-text file named [something cryptic].php. In it, put the following line: <?php phpversion(); ?>.
  2. Upload the file to your server, and visit it in a browser: http://your.server.name/whatever_you_called_that_file.php

You should see a very tall table full of variables and server settings, which you do not want to share with the world, and near the top should be the exact version of PHP your server is using.

Walter

On Oct 23, 2016, at 12:37 PM, David email@hidden wrote:

Hi, Walter-

If I just link directly to the .php page, I get this:

Notice: Use of undefined constant INPUT_POST - assumed ‘INPUT_POST’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 90

Notice: Use of undefined constant INPUT_GET - assumed ‘INPUT_GET’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 94

Notice: Use of undefined constant INPUT_POST - assumed ‘INPUT_POST’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 106

Notice: Use of undefined constant INPUT_GET - assumed ‘INPUT_GET’ in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 107

Fatal error: Call to undefined function filter_has_var() in /webstore/marylandadvocacy.com/public/test/FW_SendForm_untitled1_twoLeft.php on line 125

Is this what you’re looking for?

Later, David

The .php page is-

<?php global $errorStrings; global $errors; // CONFIG // Redirect pages $successPage = ""; // Relative path for page to redirect to on success $errorPage = ""; // Relative path for page to redirect to on error, error numbers will be in a GET variable // E-Mail $recipient = "email@hidden"; // 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 $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( 'nameField' => array( 'title' => 'nameField', 'required' => '1', 'type' => 'firstName' ), 'emailField' => array( 'title' => 'emailField', 'required' => '1', 'type' => 'from', 'filter' => 'email' ), 'subjectField' => array( 'title' => 'subjectField', 'required' => '1' ) ); // Error strings $errorStrings = array( 0 => 'Undefined error', 1 => 'No form submitted', 2 => 'Invalid E-Mail address', 3 => 'E-Mail could not be delivered', 4 => 'sendForm41541', // No real error message for this ); // 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); // Are we in safe mode? $safeMode = ini_get('safe_mode'); // safe_mode can be 'On' or true $safeMode = ($safeMode == 'On' || $safeMode == true); $recipientId = 0; // Before we go anywhere, was the form submitted by a human? if (($input_type == INPUT_POST && !empty($_POST['sendForm41541']) || ($input_type == INPUT_GET && !empty($_GET['sendForm41541'])))) { // 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 = ''; 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 (filter_input($input_type, $key, FILTER_VALIDATE_EMAIL)) { $field = $sanitized; if ($var['type'] == 'recipient') { $recipient = $field; $field = ''; } elseif ($var['type'] == 'from' && $allowsOtherDomains) $from = $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_MAGIC_QUOTES); } } else { $group = filter_input(INPUT_POST, $key, FILTER_SANITIZE_MAGIC_QUOTES, 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_MAGIC_QUOTES); } 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'] . ": $fieldn"; } } } // 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' . "rn" . 'Content-type: text/plain; charset=UTF-8' . "rn"; if ($name) $fromHeader = "From: "$name" <$from>rn"; else $fromHeader = "From: $fromrn"; if (!$allowsOtherDomains) $parameters = "-f$from"; if ($safeMode) $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader); else $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" rn"; else $fromHeader = "From: no-reply@" . $_SERVER['HTTP_HOST'] . "rn"; if ($safeMode) $mailSuccess = mail($recipient, $subject, "$emailBody", $headers . $fromHeader); else $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"); } ?>

freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Would try PHP feedback form but this is an inline page element.

PHPFF can be applied as a Page action and if you only have one form on the page you shouldn’t have any issues.

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Walter & David,

I tried the php version query and got just a blank page. Using the feedback form as a page action worked perfectly, however, so problem solved and thanks to you both for your help!

Later, David


freewaytalk mailing list
email@hidden
Update your subscriptions at: