PDA

View Full Version : Where am I going wrong: GoDaddy won't let my email process form work!


jojotoronald374823
04-06-2009, 08:49 PM
I've set up a site on GoDaddy. One page of the site is used to process a form with PHP.
The code above Doctype is: (I'm working with Dreamweaver CS4).
When the form is completely filled out and I go to submit it, GoDaddy doesn't allow it to go through (i.e. I get the error message which is embedded in my code.) If I use GoDaddy's form mail (which is also PHP in the action field of the form element (i.e. form ="/gdform.php) it goes through. The code below comes essentially from Dreamweaver CS4 by David Powers. As suggested I have used all 5 fields of the form element. I ask Dave about it, but no answer given helped. GoDaddy isn't very helpful either. Is there something that I am overlooking in the code which the server doesn't like? Any help greatly appreciated! Ron.)


<?php
$tabToShow = 0;

if (array_key_exists('send', $_POST)) {
//mail processing script
// remove escape characters from POST array
if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}

$to = 'KHPrinters@aol.com'; //use your own email address
$subject = 'Contact information for quote on job';

// list expected fields
$expected = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// set required fields
$required = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// create empty array for any missing fields
$missing = array();

// assume that there is nothing suspect
$suspect = false;

// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';

// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any subarrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
} else {

// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
} elseif (in_array($key, $expected)) {
// otherwise, assign to a variable of the same name as $key
${$key} = $temp;
}
}
}
//validate the email address
if (!empty($email)) {// regex to identify illegal characters in email address
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
//reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
$suspect = true;
$mailSent = false;
unset($missing);
}

}
// go ahead only if not suspect and all required fields OK
if (!suspect && empty($missing)) {
//build the message
$message = "Name: $name\r\n\r\n";
$message .= "Firm's name: $business\r\n\r\n";
$message .= "Street address: $addressStreet\r\n\r\n";
$message .= "City: $city\r\n\r\n";
$message .= "State: $state\r\n\r\n";
$message .= "Zip code: $zip\r\n\r\n";
$message .= "Phone number: $phone\r\n\r\n";
$message .= "Email address: $email\r\n\r\n";
$message .= "Nature of inquiry: $inquire";

// limit line lenght to 70 characters
$message = wordwrap($message, 70);
//create additional headers
$headers = "From: Kings Highway Printers<khprinters@aol.com>\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8';
if (!empty($email)) {
$headers .= "\r\nReply-To: $email";
}


// send it
$mailSent = mail($to, $subject, $message, $headers,'-fKHprinters@aol.com');
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
else{ // suspect or at least one required field missing
$tabToShow = 4;
}

The PHP code on the form page is:




<div class="TabbedPanelsContent">
<p>If you have any questions or desire any quotes, please completely fill out the form below, and we'll get back to you promptly.</p>
<?php
if ($_POST && isset($missing) && !empty($missing)) {
?>

<p class="warning">Please complete the missing item(s) indicated.</p>
<?php
} elseif ($_POST && !$mailSent) {
?>
<p class="warning">Sorry, there was a problem sending your message. Please try later.</p>
<?php
} elseif ($_POST && $mailSent) {
?>
<p id="greengo"> Your message has been sent. We will contact you soon. </p>
<?php } ?>
<form id="form1" name="form1" method="post" action= "<?php echo $_SERVER['PHP_SELF']; ?>" >
<p>

<label for="name">Name <?php
if (isset($missing) && in_array('name', $missing)) { ?>
<span class="warning">Please enter your name</span><?php } ?>

</label>
<input name="name" type="text" class="backgroundColorInput" id="name" size="35" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8').'"';
} ?>
/>
<label for="business">Firm's name <?php
if (isset($missing) && in_array('business', $missing)) { ?>
<span class="warning">Please enter your firm's name</span><?php } ?> </label>
<input name="business" type="text" class="backgroundColorInput" id="business" size="35" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['business'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="addressStreet">Street address <?php
if (isset($missing) && in_array('addressStreet', $missing)) { ?>
<span class="warning">Please enter the street address</span><?php } ?> </label>
<input name="addressStreet" type="text" class="backgroundColorInput" id="addressStreet" size="35"<?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['addressStreet'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>

<label for="city">City <?php
if (isset($missing) && in_array('city', $missing)) { ?>
<span class="warning">Please enter your City</span><?php } ?>
</label>
<input name="city" type="text" class="backgroundColorInput" id="city" size="35" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['city'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="state">State <?php
if (isset($missing) && in_array('state', $missing)) { ?>
<span class="warning">Please enter your State </span> <?php } ?> </label>
<input name="state" type="text" class="backgroundColorInput" id="state" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['state'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="zip">Zip code
<?php
if (isset($missing) && in_array('zip', $missing)) { ?>
<span class="warning"> &hellip;and your Zip</span><?php } ?> </label>


<input name="zip" type="text" class="backgroundColorInput" id="zip" size="10" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['zip'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="phone">Phone number <?php
if (isset($missing) && in_array('phone', $missing)) { ?>
<span class="warning">We may need to contact you by phone. </span><?php } ?>
</label>
<input name="phone" type="text" class="backgroundColorInput" id="phone" size="35" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['phone'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="email">Email address <?php
if (isset($missing) && in_array('email', $missing)) { ?>
<span class="warning">We will need to email you some forms.</span><?php } ?> </label>
<input name="email" type="text" class="backgroundColorInput" id="email" size="35" <?php if (isset($missing)) {
echo 'value="' .htmlentities($_POST['email'], ENT_COMPAT, 'UTF-8') .'"';
} ?>

/>
<label for="inquire">Nature of Inquiry<?php
if (isset($missing) && in_array('inquire', $missing)) { ?>
<span class="warning">Let us know what you need in the space below.</span>
<?php } ?></label>
<textarea name="inquire" cols="45" rows="5" class="backgroundColorInput" id="inquire"><?php
if (isset($missing)) {
echo htmlentities($_POST['inquire'], ENT_COMPAT, 'UTF-8'); } ?></textarea>
<label for="send"></label>
<input name="send" type="submit" id="contact" value="Contact us NOW!" />

Ray Borduin
04-07-2009, 07:00 AM
What is the error you get?

I tested with GoDaddy recently and they were throwing an error with the line breaks being used in some parts of the code.

Maybe try searching the mail.php include file for "\n" and change it to "\r\n" and see if that makes a difference. If you post back with the exact error I can probably be more sure of my answers.

pattongw387579
08-23-2009, 07:32 PM
The problem I had when that was happening was that GoDaddy doesn't let you have your form go to an aol/yahoo/msn/hotmail/gmail address, it has to be one that they provide (as far as I've discovered, I know for sure it won't let you from any other those others)...

That may be part of it...I'm a beginner, so I'm not sure if this helps.

SOJO web
08-25-2009, 12:03 PM
The problem I had when that was happening was that GoDaddy doesn't let you have your form go to an aol/yahoo/msn/hotmail/gmail address, it has to be one that they provide (as far as I've discovered, I know for sure it won't let you from any other those others)...

That may be part of it...I'm a beginner, so I'm not sure if this helps.


I would try to get some clarification from GoDaddy on their policy if you really feel that's true. If it is true, I would switch hosts as soon as possible - of course many of my applications include database user opt ins and many of them have those email address providers you mention. I could recommend some strong hosting partners if needed that I fell provide far better customer service and are just as affordable.

Cheers,

Brian

ramenfreak
08-26-2009, 01:45 PM
The problem I had when that was happening was that GoDaddy doesn't let you have your form go to an aol/yahoo/msn/hotmail/gmail address, it has to be one that they provide (as far as I've discovered, I know for sure it won't let you from any other those others)...

That may be part of it...I'm a beginner, so I'm not sure if this helps.

My form is hosted on a GoDaddy shared server and I just tested this. Adding the "/r" to the mail.php file worked. I tested this with multiple email addresses; including a gmail address.

morc.mzw383871
10-07-2009, 10:05 AM
I have surfed the forum but did not find anyone with this email issue:

(1) "Contact Us" - after I clicked "submit", I received an error message next to the email input box "Please provide your email addess so we can get back in touch with you." The emails used are XXX@gmail.com, XXX@companyxyz.com.

(2) "User Registration" page - after I clicked "Register", I received an error message next to the email input box "Please enter a valid email address."

(3) "Forgot Password" page - after I clicked "Sent", I received an error message next to the email input box "Please enter a valid email address."

Is there a general issue with my email set up (I have not altered any of the code wrt to email or mail.php).

Please advise. Thank you.

Ray Borduin
10-07-2009, 02:53 PM
Do you have a sample url where I can view the problem? Are these spry errors or errors after submitting the form?

I think I'd have to look at the page to debug the cause.

morc.mzw383871
10-07-2009, 07:43 PM
Hi,

Please go to www.xxxxxxx.com.

Thank you.

Ray Borduin
10-08-2009, 07:46 AM
OK, I'm looking at the registration page and reproducing the problem.

That is a server validation error message.

That would mean that I need to look at the server validaiton code on top of the page to spot the cause. You should be able to find the code on top of the page that refers to validation. Paste it back here and I should be able to spot the problem by looking at that code.

morc.mzw383871
10-08-2009, 12:38 PM
Thanks for your response.

(1) Since this error pertains to all email related pages, is there a general solution that I could try?

(2) How do I get the code? 1st, go to the "Registration.php" page? 2nd, run/"validate" the page to get the response? 3rd, cut and paste the response here?

Appreciate your help.

Ray Borduin
10-09-2009, 07:28 AM
Just click on the "Server Validation" server behavior if you have Validation Toolkit or Form Builder. It will highlight the code that you can cut and paste here.

If not, just look on the top of the page in Dreamweaver code view. It should be pretty easy to spot the code associated with server validation, if not, just post all of the code above the html.

morc.mzw383871
10-10-2009, 06:13 AM
Thanks Ray - pls see below: (from contactus.php - which has the same error) :

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "";
$_SESSION['WAVT_contact_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact_Name"]))?$_POST["Contact_Name"]:"") . "",true,1);
$WAFV_Errors .= WAValidateEM(((isset($_POST["Email_address"]))?$_POST["Email_address"]:"") . "",true,2);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Comments"]))?$_POST["Comments"]:"") . "",true,3);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_code"]))?strtolower($_POST["Security_code"]):"") . "",((isset($_SESSION["captcha_1"]))?strtolower($_SESSION["captcha_1"]):"") . "",true,4);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_code"]))?strtolower($_POST["Security_question"]):"") . "",((isset($_SESSION["random_answer"]))?$_SESSION["random_answer"]:"") . "",true,5);
$WAFV_Errors .= WAValidateRX(((isset($_POST["addblock"]))?$_POST["addblock"]:"") . "","/^$/i",false,6);
$WAFV_Errors .= WAValidateRX(((isset($_POST["seconddblock"]))?$_POST["seconddblock"]:"") . "","/^$/i",false,7);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"contact");
}
}
?>
<?php
if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST))) {
//WA Universal Email object="mail"
//Send Loop Once Per Entry
$RecipientEmail = "".($WAGLOBAL_Contact_Email_To) ."";include("WA_Universal_Email/WAUE_contact_1.php");

Ray Borduin
10-10-2009, 05:08 PM
I can't seem to spot the problem. I have created an incident so that somebody can look into this with you further. Please update the incident with a phone number and good time to contact you and we can help you debug this problem.

morc.mzw383871
10-12-2009, 02:30 PM
Hi Ray,

Thank you for your help.

Since the issue revolves ard emails, does it help if I change the mail.php or some other pages that has email validation information?

Or should I simply contact u guys with the "ticket"?

Thanks.

Ray Borduin
10-13-2009, 07:42 AM
Just contact us throught the ticket. We will fully investigate the problem with you there and come to a resolution quickly.