CactusProductions Posted October 24, 2010 Share Posted October 24, 2010 Hi I have a bit of code here and I can not get it to work right!!! It is a contact form from a website and the error i get is; Warning: implode() [function.implode]: Invalid arguments passed in /home/leveldte/public_html/contact-send.php on line 61 I have got no idar what to do. <?php function validateForm($data) { $errors = array(); if(empty($data['name'])) { $errors['name'] = '<p class="error">You must complete the name field</p>'; } elseif(!preg_match('/[-a-z\'` ]+/i', $data['name'])) { $errors['name'] = '<p class="error">The name you entered is not valid</p>'; } if(empty($data['email'])) { $errors['email'] = '<p class="error">You must complete the email field</p>'; } elseif(!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = '<p class="error">The email address you entered is not valid</p>'; } if(empty($data['message'])) { $errors['message'] = '<p class="error">You must enter a message</p>'; } return $errors; } function processTheForm($to) { $result = array(); if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST['middle-name'])) { $errors = validateForm($_POST); $_POST['message'] = strip_tags($_POST['message']); $subject= strip_tags($_POST['subject']); if(empty($subject)) { $subject = 'Message from '.$_POST['name']; } if(empty($errors)) { $headers = array( 'Content-type'=>'text/html', 'From'=>"{$_POST['name']}<{$_POST['email']}>", 'To'=>$to, 'Date'=>date('r') ); $mailTpl = file_get_contents('mail-template.tpl.php'); $mailTpl = str_replace(array('[name]', '', '[message]'), array($_POST['name'], $_POST['email'], $_POST['message']), $mailTpl); if(mail($to, $subject, $mailTpl, implode("\r\n", $headders))) { unset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message']); $result['mail_error'] = false; } else { $result['mail_error'] = true; } } $result['errors'] = $errors; } return $result; } Thanks for your help everyone! Daniel Link to comment https://forums.phpfreaks.com/topic/216696-error-on-send/ Share on other sites More sharing options...
revraz Posted October 24, 2010 Share Posted October 24, 2010 if(mail($to, $subject, $mailTpl, implode("\r\n", $headders))) Should that be $headers ? I would also try if(mail($to, $subject, $mailTpl, (implode("\r\n", $headers)))) Link to comment https://forums.phpfreaks.com/topic/216696-error-on-send/#findComment-1125833 Share on other sites More sharing options...
CactusProductions Posted October 24, 2010 Author Share Posted October 24, 2010 HA! A bloody spelling miskate! Thanks for your help!!! Daniel Link to comment https://forums.phpfreaks.com/topic/216696-error-on-send/#findComment-1125842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.