Jump to content

jeweline

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jeweline's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The form is now working! And I want to extend my thanks and gratiude to all of y'all. I couldn't have fixed it without your help and guidance. Chris, There was a problem with the wordwrap() function as well as the strings I was passing to mail(). I also had my $message statement wrong. With the help of everybody between 3 boards, you all contributed to my being able to have a working form. Here's the advice I got that corrected the problems: If you want to experiment here are some statements that you can use to filter all your strings that are passed to mail(). I've never worked with qmail, but according to the link generated by the error, it wants to see \r\n for the fields. Try this experiment to change all your strings in your fields before mail(): $a = preg_replace("/(?<!\\n)\\r+(?!\\n)/", "\r\n", $a); //replace just CR with CRLF $a = preg_replace("/(?<!\\r)\\n+(?!\\r)/", "\r\n", $a); //replace just LF with CRLF $a = preg_replace("/(?<!\\r)\\n\\r+(?!\\n)/", "\r\n", $a); //replace misordered LFCR Also note that the function wordwrap() by default uses just \n and there could be other places in your strings that need to be cleaned up. So if the preg_replace works, you know you'll need to go back through your code and clean up the fields properly. $message=wordwrap($message, 70, "\r\n");// use EOL Thanks again! Cynthia
  2. Chris, Here's a link I found that explains the wordwrap() function: http://us3.php.net/manual/en/function.wordwrap.php and here's the code I got when I echoed the message. It looks like the first_name variable is being printed way to often: ucfirst(First_Name): cynthia ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(evening_phone): Not selected ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(evening_phone): Not selected ucfirst(email): Not selected ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(evening_phone): Not selected ucfirst(email): Not selected ucfirst(comments): Matt, if you receive this message, please forward it to me at jeweline1961@gmail.com. Thanks, Cynthia ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(evening_phone): Not selected ucfirst(email): Not selected ucfirst(comments): Matt, if you receive this message, please forward it to me at jeweline1961@gmail.com. Thanks, Cynthia ucfirst(prefer_to_be_contacted_by): Email ucfirst(First_Name): cynthia ucfirst(Last_Name): owens ucfirst(company): Not selected ucfirst(Street_Address1): 123 anywhere street ucfirst(Street_Address2): Not selected ucfirst(city): new york ucfirst(state_region): ny ucfirst(Postal_Code): 00000 ucfirst(country_code): US ucfirst(daytime_phone): 000-000-0000 ucfirst(evening_phone): Not selected ucfirst(email): Not selected ucfirst(comments): Matt, if you receive this message, please forward it to me at jeweline1961@gmail.com. Thanks, Cynthia ucfirst(prefer_to_be_contacted_by): Email ucfirst(best_time_to_call): Morning Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4750285\html\includes\process_mail.inc.php on line 100
  3. Chris, I'm not sure how to echo the message, but I added the following in an attempt to do so: // send it echo $message; $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset ($missing); }
  4. Thanks Chris! The only place in my code where I even have the wordwrap() function is just that one time. It doesn't appear anywhere else. Here's a snippet of the code where the $message variable is initialized and the message is sent: // go ahead only if not suspect and all required fields OK if (!$suspect && empty($missing)) { // initialize the $message variable $message = ''; // loop through the $expected array foreach($expected as $item) { // assign the value of the current item to $val if (isset(${$item}) && !empty(${$item})) { $val = ${$item}; } else { // if it has no value, assign 'Not selected' $val = 'Not selected'; } // if an array, expand as comma-separated string if (is_array($val)) { $val = implode(', ', $val); } // add label and value to the message body $message .= "ucfirst($item): $val\r\n\r\n"; } // limit line length to 70 characters $message = wordwrap($message, 70); // create Reply-To header if (!empty($email)) { $headers .= "\r\nReply-To: $email"; } // send it $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset ($missing); }
  5. Ryan, I deleted the "var_dump($_POST);" statement, and tried the form again. When I clicked the submit button, I still got the following error message: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4750285\html\includes\process_mail.inc.php on line 100
  6. Ryan, I'm over my head. I'm don't understand what you're telling me: :-\ But the array is created from the following code, that appears at the very top of the form page which I was instructed to put there for debugging purposes since the form was not working: I'll take it out, and repost any error messages I get. Thanks again! <?php // JUST FOR TESTING PURPOSES prints all form variables to the screen so you can see what's being created and it's value var_dump($_POST); ?> Here's a snippet of the code for the form: <?php // JUST FOR TESTING PURPOSES prints all form variables to the screen so you can see what's being created and it's value var_dump($_POST); ?> <?php if (array_key_exists('send', $_POST)) { // mail processing script $to = 'contact@silverlinemarket.com'; $subject = 'Contact Form Inquiry from Silverline Market Website Visitor'; // list expected fields $expected = array('First_Name', 'Last_Name', 'company', 'Street_Address1', 'Street_Address2', 'city', 'state_region', 'Postal_Code', 'country_code', 'daytime_phone', 'evening_phone', 'email', 'comments', 'prefer_to_be_contacted_by', 'best_time_to_call'); //set required fields $required = array('First_Name', 'Last_Name', 'Street_Address1', 'city', 'state_region', 'Postal_Code', 'country_code', 'daytime_phone', 'comments', 'state'); // create empty array for any missing fields $missing = array(); // create additional headers $headers = "From: Silverline Market Corporation<contact@silverlinemarket.com>\r\n"; $headers .= 'Content-Type: text/plain; charset=utf-8'; $process = 'includes/process_mail.inc.php'; if (file_exists($process) && is_readable($process)) { include($process); } else { $mailSent = false; mail($to, 'Server problem', "$process cannot be read", $headers); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
  7. Hi phpORcaffine, The e-mail address to which the message is to being sent (the one set in the php code) is one hosted by the actual website. Thank you so much for looking at this for me 'cause I'm really confused! Thanks again.
  8. Thanks! I added the statement as you instructed. Here's the code I received: rray(17) { ["First_Name"]=> string(7) "Cynthia" ["Last_Name"]=> string(9) "Owens-ali" ["company"]=> string(0) "" ["Street_Address1"]=> string(7) "asdfsdf" ["Street_Address2"]=> string(4) "asfs" ["city"]=> string( "asdfasdf" ["state_region"]=> string(6) "asdfsd" ["Postal_Code"]=> string(5) "asdfa" ["country_code"]=> string(2) "JM" ["url"]=> string(0) "" ["daytime_phone"]=> string(12) "000-000-0000" ["evening_phone"]=> string(0) "" ["email2"]=> string(22) "jeweline1961@gmail.com" ["comments"]=> string(135) "Matt, I'm still testing this form. If you receive this message, please forward it to me at jeweline1961@gmail.com. Thanks, Cynthia" ["prefer_to_be_contacted_by"]=> string(5) "Phone" ["best_time_to_call"]=> string(4) "Noon" ["send"]=> string(22) "Send Us Your Comments!" } Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4750285\html\includes\process_mail.inc.php on line 100
  9. I'm sorry, I double posted this. Please see the latter post. I've attached the files in question. Thanks!
  10. Hi All, I'm still having problems with getting a contact form to submit (I've attached the files to this post.) ! Any help/guidance would be very much appreciated. I've uploaded the form on 2 servers: 1) a testing server, and 2) the actual website. The sites are not hosted by the same company. The problem now is that the form works on my testing server (Form located here: http://www.buypuresilverbullion.com/silverlinemarket2/contactus.php). But the same form (that consists of the same files) won't work on the actual website located here: (http://www.silverlinemarket.com/contactus.php) Whenever I correctly fill out the form on the actual web site, I get the following error message: [b]Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4750285\html\includes\process_mail.inc.php on line 100[/b] This message is referring to some kind of problem with carriage returns and line feeds when the message is building. Here's the php statement that builds the body of the e-mail message: // add label and value to the message body $message .= "ucfirst($item): $val\r\n\r\n"; Here's all the code in the include file, process_mail.inc.php: <?php if (isset($_SERVER['SCRIPT_NAME']) && strpos($_SERVER['SCRIPT_NAME'], '.inc.php')) exit; // 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); } // 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)) { // initialize the $message variable $message = ''; // loop through the $expected array foreach($expected as $item) { // assign the value of the current item to $val if (isset(${$item}) && !empty(${$item})) { $val = ${$item}; } else { // if it has no value, assign 'Not selected' $val = 'Not selected'; } // if an array, expand as comma-separated string if (is_array($val)) { $val = implode(', ', $val); } [b]// add label and value to the message body $message .= "ucfirst($item): $val\r\n\r\n";[/b] } // limit line length to 70 characters $message = wordwrap($message, 70); // create Reply-To header if (!empty($email)) { $headers .= "\r\nReply-To: $email"; } // send it $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset ($missing); } } ?> [attachment deleted by admin]
  11. Hi All, I'm still having problems with getting a contact form to submit! Any help/guidance would be very much appreciated. I've uploaded the form on 2 servers: 1) a testing server, and 2) the actual website. The sites are not hosted by the same company. The problem now is that the form works on my testing server (Form located here: http://www.buypuresilverbullion.com/silverlinemarket2/contactus.php). But the same form (that consists of the same files) won't work on the actual website located here: (http://www.silverlinemarket.com/contactus.php) Whenever I correctly fill out the form on the actual web site, I get the following error message: [b]Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4750285\html\includes\process_mail.inc.php on line 100[/b] This message is referring to some kind of problem with carriage returns and line feeds when the message is building. Here's the php statement that builds the body of the e-mail message: // add label and value to the message body $message .= "ucfirst($item): $val\r\n\r\n"; Here's all the code in the include file, process_mail.inc.php: <?php if (isset($_SERVER['SCRIPT_NAME']) && strpos($_SERVER['SCRIPT_NAME'], '.inc.php')) exit; // 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); } // 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)) { // initialize the $message variable $message = ''; // loop through the $expected array foreach($expected as $item) { // assign the value of the current item to $val if (isset(${$item}) && !empty(${$item})) { $val = ${$item}; } else { // if it has no value, assign 'Not selected' $val = 'Not selected'; } // if an array, expand as comma-separated string if (is_array($val)) { $val = implode(', ', $val); } [b]// add label and value to the message body $message .= "ucfirst($item): $val\r\n\r\n";[/b] } // limit line length to 70 characters $message = wordwrap($message, 70); // create Reply-To header if (!empty($email)) { $headers .= "\r\nReply-To: $email"; } // send it $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset ($missing); } } ?>
  12. PFMaBiSmAd, Thanks so much for the tiip! I changed the submit button from an image to the standard button and it worked! Thanks again!
  13. PFMaBiSmAd, I checked my code, and it looks fine as compared to the example. The example: When submitting a form, it is possible to use an image instead of the standard submit button with a tag like: <input type="image" src="image.gif" name="foo" /> My code is <input type="image"src="images/contactmedia/contact_btn.png" alt="Submit button" name="send" id="sendusyourcomments" value="Send us your comments!" /> But I'll take the image out and use the try the standard form button. Thanks again.
  14. Hi All, I am a newbie to this forum and a newbie to scripting. In fact this is my first type trying to make a form work. I've created a PHP contact form that when the submit button is clicked, I want it to send an e-mail to a certain address. Thanks so much for taking the time to look at this and help me! I'm so confused and frustrated! :banghead: Any help offered would be greatly appreciated. Thanks! I created the form in Dreamweaver. I first added code for server-side verification of the fields and then I used Dreamweaver's Spry Validation widgets to add client-side verification of the form elements. In Firefox and Google Chrome, when I test the form by correctly filling out the different form elements and clicking the submit button: the form gets submitted the "thank you" message correctly displays and I receive an e-mail in my mailbox The problem is with Internet Explorer 8. When I test the form by correctly completing the various form elements and clicking the submit button: The form doesn't get submitted because I see the following statement "Sorry, there was a problem sending your message. Please try later." This statement displays because part of an "If-then-else" statement failed. It is part of the client-side verification code I created Since, the form wasn't submitted, I don't get the resulting e-mail. I really don't know enough about PHP to debug. All I can figure is that for some reason IE thinks the $_POST and $mailSent variables are empty, so it displays the "sorry, there was a problem" error message. Here's a link to the form I'm testing: http://www.buypuresilverbullion.com/silverlinemarket2/contactus.php [b]Here's the code I'm using in the contact form page to display either error messages or a confirmation message:[/b] <?php if ($_POST && isset($missing) && !empty($missing)) { ?> <p class="warning2"><strong>Please complete the missing item(s) indicated.</strong></p> <?php } elseif ($_POST && !$mailSent) { ?> <p class="warning2">Sorry, there was a problem sending your message. Please try later.</p> <?php } elseif ($_POST && $mailSent) { ?> <p class="acknowledgement"><strong>Thanks so much for taking the time to send us a note! We’ve received your message, and will contact you shortly!</strong></p> <?php } ?> Here's the code of the include file that contains the script to process the form: <?php if (isset($_SERVER['SCRIPT_NAME']) && strpos($_SERVER['SCRIPT_NAME'], '.inc.php')) exit; // 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); } // 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)) { // initialize the $message variable $message = ''; // loop through the $expected array foreach($expected as $item) { // assign the value of the current item to $val if (isset(${$item}) && !empty(${$item})) { $val = ${$item}; } else { // if it has no value, assign 'Not selected' $val = 'Not selected'; } // if an array, expand as comma-separated string if (is_array($val)) { $val = implode(', ', $val); } // add label and value to the message body $message .= ucfirst($item).": $val\n\n"; } // limit line length to 70 characters $message = wordwrap($message, 70); // create Reply-To header if (!empty($email)) { $headers .= "\r\nReply-To: $email"; } // send it $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset($missing); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.