acmoreu Posted December 16, 2012 Share Posted December 16, 2012 (edited) Dear readers and coders, I have to recognize I do not have any idea on coding, but not having enought fund to hire a coder I have to do it myself, but some time I cannot solve the issue, and that is the reason I am posting this topic. I need a Html form trasmiting to a PHP code all fields and this last sending it to my email account. For that I got a free basic code and try to modify to my need but without success. The script give an error when all fields are listed in the mail (?) working fine just with the original field "$Comments". Can any of you tell me the problem or get this script to work. I award with 10 USD paid by paypal to the first put this code to work properly. ###### Script ############# <?php $to = "acmoreu@terra.es"; ini_set("SMTP","localhost"); $quotation_page = "quotation_form.html"; $error_page = "error_message.html"; $thankyou_page = "thank_you.html"; $company = $_REQUEST['company'] ; $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email_address = $_REQUEST['email_address'] ; $products = $_REQUEST['products'] ; $items = $_REQUEST['items'] ; $area = $_REQUEST['area'] ; $date = $_REQUEST['date'] ; $address = $_REQUEST['address'] ; $city = $_REQUEST['city'] ; $province = $_REQUEST['province'] ; $country = $_REQUEST['country'] ; $comments = $_REQUEST['comments'] ; function isInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } // If the user tries to access this script directly, redirect them to the quotation form, if (!isset($_REQUEST['email_address'])) { header( "Location: $quotation_page" ); } // If the form fields are empty, redirect to the error page. elseif (empty($email_address) || empty($comments)) { header( "Location: $error_page" ); } // If email injection is detected, redirect to the error page. elseif ( isInjected($email_address) ) { header( "Location: $error_page" ); } // If we passed all previous tests, send the email then redirect to the thank you page. else { mail( "$to", "Quotation Request - Flexypatch", "$company", "$name", "$phone", $products, $items, $area, $date, $address, $city, $province, $country, $comments, "From: $email_address" ); header( "Location: $thankyou_page" ); } ?> ############# Errors ################### Warning: mail() expects at most 5 parameters, 15 given in D:\hshome\klassmar\flexypatch.com\Quotation\send_mail.php on line 59 Warning: Cannot modify header information - headers already sent by (output started at D:\hshome\klassmar\flexypatch.com\Quotation\send_mail.php:59) in D:\hshome\klassmar\flexypatch.com\Quotation\send_mail.php on line 60 I can provide the html pages code of the filling form, if need. Thanks! error_message.html quotation_form.html send_mail.php thank_you.html Edited December 16, 2012 by acmoreu Quote Link to comment https://forums.phpfreaks.com/topic/272053-php-code-error-html-fields-post-by-mail/ Share on other sites More sharing options...
TOA Posted December 16, 2012 Share Posted December 16, 2012 The error message is telling you what is going on...you're giving too many parameters to mail(). What you need to do is combine all the fields you want in the email into a variable named something like $message, and then look at the manual page for mail(). Quote Link to comment https://forums.phpfreaks.com/topic/272053-php-code-error-html-fields-post-by-mail/#findComment-1399661 Share on other sites More sharing options...
kimi2k Posted December 16, 2012 Share Posted December 16, 2012 Really, you send to mail so much parameters, read the documentation for mail(). also try phpmailer... Quote Link to comment https://forums.phpfreaks.com/topic/272053-php-code-error-html-fields-post-by-mail/#findComment-1399664 Share on other sites More sharing options...
acmoreu Posted December 16, 2012 Author Share Posted December 16, 2012 Thanks any how, I finally got the solution. I have to list the field as follows "$comments, $address.....". Now works. Quote Link to comment https://forums.phpfreaks.com/topic/272053-php-code-error-html-fields-post-by-mail/#findComment-1399665 Share on other sites More sharing options...
Jessica Posted December 16, 2012 Share Posted December 16, 2012 So, exactly what TOA said. Quote Link to comment https://forums.phpfreaks.com/topic/272053-php-code-error-html-fields-post-by-mail/#findComment-1399687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.