I’m working on a feedback form that will eventually include the reCaptcha routine, but I am stumped on a more basic problem.
When I use the form as a stand-alone php document, the php mail() function works perfectly, and I receive the email properly formatted. But when I paste this same code into a Freeway page, the mail() function fails.
I’ve tried using both the PHP Block action, and alternately adding the code as a Markup Item. In each case the feedback form works perfectly, EXCEPT for the mail() function. There are no other actions on the Freeway page.
So what is it that is preventing the mail() function from working from within a Freeway-generated page? Is there a better way to accomplish this? (I’m not using one of the actions, because I am working with the PHP Form Builder Class (which I just discovered and is pretty neat.)
Thanks for any guidance anyone might have.
The php code, if it will help, is as follows:
<?php # formtest.php // Include the PHP Form Builder Class include("../php-form-builder-class/class.form.php"); // Initialize a new session session_start(); // See if the form has already been submitted if (ISSET($_POST['cmd'])) { // Get the values from the form $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $email = $_POST['email']; $mess = $_POST['message']; // Setup the mail fields $to = 'email@hidden'; $subject = 'Message from website user'; $message = "$fname $lname sent the following message through the mimobic website:" . "rn" . "Phone number: $phone" . "rn" . "Email address: $email" . "rn" . "rn" . "MESSAGE:" . "rn" . wordwrap($mess, 70); $headers = 'From: email@hidden'; // Send the email if (mail($to, $subject, $message, $headers)) { // If the mail was sent, provide a confirmation to the user echo "Thanks for contacting us. If your message requires a response, we'll get back to you as soon as possible."; } else { // If the mail was NOT sent, ask the user to try again echo "Oops! There was some problem with sending your message - please click your browser's 'Back' button and try sending again. If this persists, please contact us by telephone at 111-555-1212. We apologize for the inconvenience."; } // If the form hasn't yet been submitted, then display it } else { // Display the initial welcome message echo "Please contact us with questions, concerns, or requests. If you'd like a response, please make sure that you've provided a telephone number or email address, so that we know how to get back to you."; // Set up the form attributes $form = new form("Contact_Us"); $form->setAttributes(array( "width" => 600, "map" => array(2, 2, 1), "action" => "formtest.php" )); // Remove offending characters if(!empty($_GET["errormsg_0"])) $form->errorMsg = filter_var(stripslashes($_GET["errormsg_0"]), FILTER_SANITIZE_SPECIAL_CHARS); // Display the form fields $form->addHidden("cmd", "submit_0"); $form->addTextbox("First Name", "fname"); $form->addTextbox("Last Name", "lname"); $form->addEmail("Email Address", "email"); $form->addTextbox("Phone Number", "phone"); $form->addTextarea("Message", "message"); $form->addButton(); $form->render(); // Finish off the form display echo "
"; } ?>
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options