close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

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

Thread began 4/06/2009 11:49 pm by jojotoronald374823 | Last modified 10/13/2009 10:42 am by Ray Borduin | 9069 views | 14 replies |

jojotoronald374823

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

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!" />

Sign in to reply to this post

Ray BorduinWebAssist

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.

Sign in to reply to this post

pattongw387579

Problem I had...

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.

Sign in to reply to this post

anonymous

Originally Said By: pattongw387579
  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

Sign in to reply to this post

jcmiyake381521

Originally Said By: pattongw387579
  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.

Sign in to reply to this post

morc.mzw383871

Powerstore v2 email issues (contact form, user registration, forgot password, etc)

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.

Sign in to reply to this post

Ray BorduinWebAssist

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.

Sign in to reply to this post

morc.mzw383871

Contact Form/Email does not work

Hi,

Please go to www.xxxxxxx.com.

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

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.

Sign in to reply to this post

morc.mzw383871

Email Validation Error

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.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...